From caaaaedc116039a83816de949562063b9a24529c Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Wed, 21 Nov 2012 05:10:25 +0000 Subject: [PATCH] Workaround to avoid exceptions in FindNode() when an Int64 from TDBQuery.RecNo comes in and gets compared to the Cardinal typed VTree.Node.Index. --- source/helpers.pas | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/source/helpers.pas b/source/helpers.pas index 1527f0ff..9b18532d 100644 --- a/source/helpers.pas +++ b/source/helpers.pas @@ -1610,20 +1610,17 @@ var begin // Helper to find a node by its index 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 - Node := VT.GetFirstChild(ParentNode) - else - Node := VT.GetFirst; - while Assigned(Node) do begin - if Node.Index = idx then begin - Result := Node; - break; - end; - Node := VT.GetNextSibling(Node); + if Assigned(ParentNode) then + Node := VT.GetFirstChild(ParentNode) + else + Node := VT.GetFirst; + while Assigned(Node) do begin + // Note: Grid.RootNodeCount is unfortunately Cardinal, not UInt64. + if Node.Index = idx then begin + Result := Node; + break; end; + Node := VT.GetNextSibling(Node); end; end;