List index out of bounds when adding column to TStringGrid
Original Reporter info from Mantis: cobines
-
Reporter name:
Original Reporter info from Mantis: cobines
- Reporter name:
Description:
When you add columns via Columns.Add the program may crash with the exception quoted below, because it tries to repaint columns based on ColCount number, when they might not exist in Columns collection. By default ColCount states that there are 5 columns, but Columns.Count has 0 items. The bug doesn't happen if you have the grid as a resource in LFM probably because some properties are assigned at the start of the program.
The attached example program causes exception when you press the button:
TApplication.HandleException List index (1) out of bounds
Stack trace:
$0809B044 TFPLIST__ERROR, line 157 of /home/devel/fpc/rtl/objpas/classes/lists.inc
$0809ABBF TFPLIST__RAISEINDEXERROR, line 48 of /home/devel/fpc/rtl/objpas/classes/lists.inc
$0809AC00 TFPLIST__GET, line 54 of /home/devel/fpc/rtl/objpas/classes/lists.inc
$0809BEAF TLIST__GET, line 543 of /home/devel/fpc/rtl/objpas/classes/lists.inc
$0809A4EF TCOLLECTION__GETITEM, line 270 of /home/devel/fpc/rtl/objpas/classes/collect.inc
$0828E587 TGRIDCOLUMNS__GETCOLUMN, line 9908 of grids.pas
$0827ED8B TCUSTOMGRID__COLUMNFROMGRIDCOLUMN, line 4830 of grids.pas
$08277E05 TCUSTOMGRID__GETCOLWIDTHS, line 2155 of grids.pas
$0827EBCA TCUSTOMGRID__COLROWTOOFFSET, line 4794 of grids.pas
$08279869 TCUSTOMGRID__CELLRECT, line 2806 of grids.pas
$082825EB TCUSTOMGRID__INVALIDATERANGE, line 6270 of grids.pas
$08277B5F TCUSTOMGRID__INVALIDATEMOVEMENT, line 2084 of grids.pas
$0828194F TCUSTOMGRID__MOVEEXTEND, line 5933 of grids.pas
$08281BFB TCUSTOMGRID__MOVENEXTSELECTABLE, line 6005 of grids.pas
$0827D1F6 TCUSTOMGRID__CHECKCOUNT, line 4194 of grids.pas
$08277652 TCUSTOMGRID__INTERNALSETCOLCOUNT, line 1963 of grids.pas
$0827EE46 TCUSTOMGRID__COLUMNSCHANGED, line 4845 of grids.pas
$0828E63F TGRIDCOLUMNS__UPDATE, line 9944 of grids.pas
$0809A4C8 TCOLLECTION__CHANGED, line 264 of /home/devel/fpc/rtl/objpas/classes/collect.inc
$0809A216 TCOLLECTION__INSERTITEM, line 213 of /home/devel/fpc/rtl/objpas/classes/collect.inc
$08099A4C TCOLLECTIONITEM__SETCOLLECTION, line 35 of /home/devel/fpc/rtl/objpas/classes/collect.inc
$08099D45 TCOLLECTIONITEM__CREATE, line 108 of /home/devel/fpc/rtl/objpas/classes/collect.inc
$0828E211 TGRIDCOLUMN__CREATE, line 9852 of grids.pas
$0809A6C7 TCOLLECTION__ADD, line 309 of /home/devel/fpc/rtl/objpas/classes/collect.inc
$0828EA11 TGRIDCOLUMNS__ADD, line 10023 of grids.pas
$0808ED85 TFORM1__BUTTON1CLICK, line 44 of unit1.pas
$08192974 TCONTROL__CLICK, line 2305 of ./include/control.inc
$081D784F TBUTTONCONTROL__CLICK, line 72 of ./include/buttoncontrol.inc
$081D7E46 TCUSTOMBUTTON__CLICK, line 164 of ./include/buttons.inc
$081D83A1 TBUTTON__CLICK, line 331 of ./include/buttons.inc
$081D76EA TBUTTONCONTROL__WMDEFAULTCLICKED, line 26 of ./include/buttoncontrol.inc
$0806CE81 TOBJECT__DISPATCH, line 472 of /home/devel/fpc/rtl/inc/objpas.inc
$0819195F TCONTROL__WNDPROC, line 1654 of ./include/control.inc
Using Lazarus SVN rev. 24057.
Mantis conversion info:
- Mantis ID: 16021
- OS: Debian
- OS Build: Sid
- Platform: Linux-i386
- Version: 0.9.29 (SVN)
- Fixed in version: 0.9.29 (SVN)
- Fixed in revision: 24070 (#d83ee652)
- Target version: 0.9.30