[DUG] Is it a bug in latest version of Delphi?
Karl Reynolds
kreynolds at chocfishsoft.co.nz
Tue Feb 16 13:17:56 NZDT 2010
On Tue, Feb 16, 2010 at 11:55 AM, Jolyon Smith <jsmith at deltics.co.nz> wrote:
> function ListBoxGetObject(const aListBox: TListBox; const aIndex: Integer):
> TObject;
> begin
> if (aIndex < 0) or (aIndex >= aListBox.Items.Count) then
> TStringsHelper(aListBox.Items).Error(SListIndexError, aIndex);
>
> result := TObject(TListBoxHelper(aListBox).GetItemData(aIndex));
> end;
You should still allow for other funky errors occurring, like out of
memory. So I would throw an extra line at the end:
if GetLastError <> 0 then RaiseLastOSError;
And then if you do that, I could argue that it's excessive to check
for the bounds explicitly beforehand, since windows does that
internally anyway. It really comes down to whether you like the OS
error message or not.
Cheers,
Karl
More information about the Delphi
mailing list