[DUG] Is it a bug in latest version of Delphi?

Jolyon Smith jsmith at deltics.co.nz
Tue Feb 16 12:16:50 NZDT 2010


> you should care greatly, because this is violating OOP principles 

I care about code that works and gets a job of work done.  "OO Principles" are for the classroom.


> Obviously the GetObject source cares somewhat about what -1 points to.

No, it doesn't.  It simply gets confused because the Windows API uses "-1" to indicate that an error occurred in retrieving an item's data and the VCL is then naively assuming that ANY error in retrieving an item's data must be a List Index error.

Even though it could (and should) specifically test for index validity before calling the API and so discount that possible source of an error from the outset.

Indeed, the TObject(-1) result is cast BACK to a LongInt(-1) for testing against the simple value LB_ERR (which == -1) ... the source of this error has nothing what-so-ever to do with the casting of the value as TObject.





More information about the Delphi mailing list