From dc4e6c980a9dd0fd4c7cb0141a539bba4aeaf393 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Mon, 8 Feb 2010 20:57:07 +0000 Subject: [PATCH] Prefer VT.FocusedNode over VT.GetFirstSelected in various places. Clicking a node twice deselects it and subsequent actions have an access violation. Fixes issue #1674. --- source/main.pas | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/main.pas b/source/main.pas index bf3e0e8a..4491d236 100644 --- a/source/main.pas +++ b/source/main.pas @@ -4488,7 +4488,7 @@ begin // Check for allowed controls as source has already // been performed in OnDragOver. So, only do typecasting here. if src = DBtree then begin - TreeNode := DBtree.GetFirstSelected; + TreeNode := DBtree.FocusedNode; Text := mask(DBtree.Text[TreeNode, 0]); if DBtree.GetNodeLevel(TreeNode) = 2 then Text := mask(DBtree.Text[TreeNode.Parent, 0]) + '.' + Text; @@ -6087,7 +6087,7 @@ begin if not (Kind in [ikNormal, ikSelected]) then Exit; case Sender.GetNodeLevel(Node) of 0: ImageIndex := ICONINDEX_SERVER; - 1: if (Kind = ikSelected) or ((Sender.GetFirstSelected<>nil) and (Node=Sender.GetFirstSelected.Parent)) then + 1: if (Kind = ikSelected) or ((Sender.FocusedNode<>nil) and (Node=Sender.FocusedNode.Parent)) then ImageIndex := ICONINDEX_DB_HIGHLIGHT else ImageIndex := ICONINDEX_DB; 2: begin @@ -6329,7 +6329,7 @@ var Node: PVirtualNode; begin // Paste DB or table name into query window on treeview double click. - Node := DBtree.GetFirstSelected; + Node := DBtree.FocusedNode; if not Assigned(Node) then Exit; if DBtree.GetNodeLevel(Node) = 0 then Exit; if not QueryTabActive then Exit; @@ -6481,7 +6481,7 @@ end; procedure TMainForm.menuTreeExpandAllClick(Sender: TObject); begin DBtree.FullExpand; - DBtree.ScrollIntoView(DBtree.GetFirstSelected, False); + DBtree.ScrollIntoView(DBtree.FocusedNode, False); end; {** @@ -6497,7 +6497,7 @@ begin DBtree.FullCollapse(n); n := DBtree.GetNextSibling(n); end; - DBtree.ScrollIntoView(DBtree.GetFirstSelected, False); + DBtree.ScrollIntoView(DBtree.FocusedNode, False); end;