[lazarus] a wierd crash in an apllication with StringGrid

LeVA leva at az.isten.hu
Sat Dec 27 16:18:06 EST 2003


Hi!

I don't know if this is a bug, or not. I'll just explain what happened, 
and then it's up to you to decide it.

I've put a StringGrid to my Form, and filled it up with data from a 
file. The StringGrid1.Scrollbars is set to 'SSAUTOVERTICAL', so if the 
data is "too much" a scrollbar will appear. I have a 'refresh' button on 
the same Form, and when I click on it, the data will be rereaded from 
the data file, and the StringGrid will be filled up with the new data.
In the beginning this StringGrid has only two rows. One fixed (for the 
headers) and one empty (this is necesary if I have a fixed row). During 
the filling up, I'm increasing the RowCount after each row adding, so 
the RowCount-1 will be equal with the newly added rows.
When I push that 'refresh' button, I want to reset the RowCount 
(otherwise I'll get a lot of empty rows). So, when I click the 'refresh' 
button, it's doing this:
StringGrid1.RowCount := 2;

And the filling comes after that.

Now the StringGrid has filled, and the scrollbar has appeared, and I 
scrolled down until I saw the last element. If then I click the refresh 
button, my whole application crashes, and I get this error message in 
the console (it's because of the StringGrid1.RowCount := 2, not 
especialy of the 'refresh' button):

TApplication.HandleException List index exceeds bounds (3)
TApplication.HandleException: there was another exception during showing 
the first exception
[TgtkObject.Destroy] WARNING: There are 1 unreleased DCs, a detailed 
dump follows:
[TgtkObject.Destroy]  DCs:   083C0494
[TgtkObject.Destroy] WARNING: There are 3 unreleased GDIObjects, a 
detailed dump follows:
[TgtkObject.Destroy]   GDIOs: 08394734 08394794 08394A34
[TgtkObject.Destroy]   gdiBrush: 1
[TgtkObject.Destroy]   gdiFont: 1
[TgtkObject.Destroy]   gdiPen: 1

So in the StringGrid if I scrolled down to the last element, and after I 
set the rowcount less than the existing rows, it crashes.
Hope that this is understandable, I gathered my whole english knowledge 
to write this letter :) I know it could've been better.
Please ask me if you don't understand what the problem is.

ps.: I have changed my application, so it will only add new rows during 
the filling up if it is realy necesary, and I commented the Rowcount 
setting out, so it is working fine, but I think that it has to work in 
the other way too.

Thanks!

Daniel


-- 
LeVA






More information about the Lazarus mailing list