Workaround to avoid exceptions in FindNode() when an Int64 from TDBQuery.RecNo comes in and gets compared to the Cardinal typed VTree.Node.Index.

This commit is contained in:
Ansgar Becker
2012-11-21 05:10:25 +00:00
parent b6a18114f4
commit caaaaedc11

View File

@ -1610,14 +1610,12 @@ var
begin begin
// Helper to find a node by its index // Helper to find a node by its index
Result := nil; Result := nil;
// Grid.RootNodeCount is unfortunately Cardinal, not Int64.
// Work around that as long as VT does not change that.
if (idx >= Low(Cardinal)) or (idx <= High(Cardinal)) then begin
if Assigned(ParentNode) then if Assigned(ParentNode) then
Node := VT.GetFirstChild(ParentNode) Node := VT.GetFirstChild(ParentNode)
else else
Node := VT.GetFirst; Node := VT.GetFirst;
while Assigned(Node) do begin while Assigned(Node) do begin
// Note: Grid.RootNodeCount is unfortunately Cardinal, not UInt64.
if Node.Index = idx then begin if Node.Index = idx then begin
Result := Node; Result := Node;
break; break;
@ -1625,7 +1623,6 @@ begin
Node := VT.GetNextSibling(Node); Node := VT.GetNextSibling(Node);
end; end;
end; end;
end;
procedure SelectNode(VT: TVirtualStringTree; idx: Int64; ParentNode: PVirtualNode=nil); overload; procedure SelectNode(VT: TVirtualStringTree; idx: Int64; ParentNode: PVirtualNode=nil); overload;