Skip to content

Commit f76c54f

Browse files
committed
fix: sporadic crash in DBtreePaintText with columns
Also, do not init column nodes in FindDBObjectNode, after dblclick on a table in ListTables Refs #2069
1 parent 9f83561 commit f76c54f

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

source/main.pas

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8627,14 +8627,16 @@ function TMainForm.FindDBObjectNode(Tree: TVirtualStringTree; Obj: TDBObject): P
86278627
end;
86288628

86298629
// Search in grouped table/view/... nodes
8630-
GroupedNode := Tree.GetFirstChild(ObjectNode);
8631-
while Assigned(GroupedNode) do begin
8632-
GroupedObj := Tree.GetNodeData(GroupedNode);
8633-
if GroupedObj.IsSameAs(Obj) then begin
8634-
Result := GroupedNode;
8635-
break;
8630+
if ObjectObj.NodeType = lntGroup then begin
8631+
GroupedNode := Tree.GetFirstChild(ObjectNode);
8632+
while Assigned(GroupedNode) do begin
8633+
GroupedObj := Tree.GetNodeData(GroupedNode);
8634+
if GroupedObj.IsSameAs(Obj) then begin
8635+
Result := GroupedNode;
8636+
break;
8637+
end;
8638+
GroupedNode := Tree.GetNextSibling(GroupedNode);
86368639
end;
8637-
GroupedNode := Tree.GetNextSibling(GroupedNode);
86388640
end;
86398641

86408642
ObjectNode := Tree.GetNextSibling(ObjectNode);
@@ -10289,8 +10291,10 @@ procedure TMainForm.DBtreePaintText(Sender: TBaseVirtualTree; const
1028910291
if DBObj.NodeType = lntColumn then begin
1029010292
ParentObj := Sender.GetNodeData(Node.Parent);
1029110293
Columns := ParentObj.TableColumns;
10292-
Datatype := Columns[Node.Index].DataType;
10293-
TargetCanvas.Font.Color := AppColorSchemes.First.GridTextColors[Datatype.Category];
10294+
if Columns.Count > Node.Index then begin
10295+
Datatype := Columns[Node.Index].DataType;
10296+
TargetCanvas.Font.Color := AppColorSchemes.First.GridTextColors[Datatype.Category];
10297+
end;
1029410298
end;
1029510299
end;
1029610300
1: begin // Grey out rather unimportant "Size" column

0 commit comments

Comments
 (0)