2013/9/12 Jürgen Hestermann <[email protected]> > 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. >
Once again, I did not look at the code. My remarks only come from my memories of how VirtualTreeView worked with Delphi 6. The code has obviously much changed since. I was only attempting to answer to your question: this is probably the reason. Is it still working? Obviously not. What should be done? I see 2 options: either restore the old functionality if needed or (if indeed this test never had any real use) remove this test from the example. How does code handle when AbsoluteIndex does not find an item? I just took a look at v5.2.0. If I read the code correctly, if the parameter is the root, AbsoluteIndex will answer 0. If the parameter is not found, AbsoluteIndex will answer 0 too. Is this deliberate? > 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. > Now yes. Once upon a time maybe not. -- Frederic Da Vitoria (davitof) Membre de l'April - « promouvoir et défendre le logiciel libre » - http://www.april.org
-- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
