[Lazarus] VirtualTreeView, Absoluteindex example on freepascal.org

Jürgen Hestermann juergen.hestermann at gmx.de
Thu Sep 12 17:36:40 CEST 2013


Am 2013-09-12 14:50, schrieb Frederic Da Vitoria:
>
>     Can someone explain what the line
>       if VST.AbsoluteIndex(XNode) > -1 then
>     actually means?
>
>
> I didn't look at the code, but usually index = -1 means that the item was not found. So maybe AbsoluteIndex's result should actually be signed?

And how would it ever reach the value -1?
Obviously there is no code that sets it to this value,
otherwise it would not compile with Cardinal type.


> In this example, I guess the test is to avoid a bug if AddChild does not manage to insert the root node. I don't know if AddChild could create a node without inserting, but this is what the code seems to be testing.
>
But it is a useless "if" statement that doesn't test anything.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130912/e6c4ed69/attachment-0003.html>


More information about the Lazarus mailing list