Skip to content

Commit 59ea39a

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 cbdc78d commit 59ea39a

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
@@ -8638,14 +8638,16 @@ function TMainForm.FindDBObjectNode(Tree: TBaseVirtualTree; Obj: TDBObject): PVi
86388638
end;
86398639

86408640
// Search in grouped table/view/... nodes
8641-
GroupedNode := Tree.GetFirstChild(ObjectNode);
8642-
while Assigned(GroupedNode) do begin
8643-
GroupedObj := Tree.GetNodeData(GroupedNode);
8644-
if GroupedObj.IsSameAs(Obj) then begin
8645-
Result := GroupedNode;
8646-
break;
8641+
if ObjectObj.NodeType = lntGroup then begin
8642+
GroupedNode := Tree.GetFirstChild(ObjectNode);
8643+
while Assigned(GroupedNode) do begin
8644+
GroupedObj := Tree.GetNodeData(GroupedNode);
8645+
if GroupedObj.IsSameAs(Obj) then begin
8646+
Result := GroupedNode;
8647+
break;
8648+
end;
8649+
GroupedNode := Tree.GetNextSibling(GroupedNode);
86478650
end;
8648-
GroupedNode := Tree.GetNextSibling(GroupedNode);
86498651
end;
86508652

86518653
ObjectNode := Tree.GetNextSibling(ObjectNode);
@@ -10350,8 +10352,10 @@ procedure TMainForm.DBtreePaintText(Sender: TBaseVirtualTree; const
1035010352
if DBObj.NodeType = lntColumn then begin
1035110353
ParentObj := Sender.GetNodeData(Node.Parent);
1035210354
Columns := ParentObj.TableColumns;
10353-
Datatype := Columns[Node.Index].DataType;
10354-
TargetCanvas.Font.Color := DatatypeCategories[Datatype.Category].Color;
10355+
if Columns.Count > Node.Index then begin
10356+
Datatype := Columns[Node.Index].DataType;
10357+
TargetCanvas.Font.Color := DatatypeCategories[Datatype.Category].Color;
10358+
end;
1035510359
end;
1035610360
end;
1035710361
1: begin // Grey out rather unimportant "Size" column

0 commit comments

Comments
 (0)