View Issue Details

IDProjectCategoryView StatusLast Update
0026916LazarusDatabase Componentspublic2014-10-22 17:30
ReporterLuca Olivetti Assigned ToJesus Reyes  
Status closedResolutionfixed 
Product Version1.2.6 
Target Version1.4Fixed in Version1.3 (SVN) 
Summary0026916: TDBGrid on a TPageControl generates "List index out of bounds" error due to spurious exit event
DescriptionWhen you place a TDbgrid on a TTabSheet while appending a record and clicking on another cell of the same record, a spurious exit event is generated which cancels the edit and eventually causes a "list index out of bounds" error since the record is no longer there.
No such spurious exit event is generated if there's no TPageControl/TTabSheet on the form.
Steps To ReproduceIn the attached project:
1) go to the last record in either grid
2) use the keyboard down arrow. A new record is appended. Don't type anything in the edit box
3) use the mouse to click on another cell of the same (appended) record

A "list index out of bounds" exception is generated. If you then click the button to remove the pagecontrol and repeat the steps, no exception is generated.
Additional InformationIf you put a breakpoint on the procedure TCustomDBGrid.DoExit (lcl/dbgrids.pas) you'll see that step 3 will trigger the breakpoint when there's a pagecontrol and won't trigger it without.
That procedure will cancel the edit, hence causing the exception.
As a workaround I set dgCancelOnEdit to false, so that the procedure doesn't cancel the edit.
Tagsdbgrid, TPageControl
Fixed in Revision46642
Attached Files


Luca Olivetti

2014-10-21 12:54

reporter (3,418 bytes)

Luca Olivetti

2014-10-21 12:59

reporter   ~0078456

It seems to be specific to win32, doesn't happen with linux/gtk or linux/qt

Luca Olivetti

2014-10-21 15:47

reporter (2,718 bytes)

Luca Olivetti

2014-10-21 15:52

reporter   ~0078471

It turns out that the TPagecontrol/TTabsheet was a red herring (but I cannot change the summary): it's enough to put 2 dbgrids in the same form, as in the attached
The strange thing is that it only happens to the grid on the right (which I copy-pasted from the other one), but if I delete the first one (with the button) then the bogus exit event isn't generated.
Note also that it only happens with dgAlwaysShowEditor (which I need to set to overcome another limitation of the TDBGrid).

Jesus Reyes

2014-10-22 16:00

developer   ~0078520

Please test.

This patch can be merged to fixes if needed.

Luca Olivetti

2014-10-22 17:30

reporter   ~0078529

Thanks Jesús that was fast.

Issue History

Date Modified Username Field Change
2014-10-21 12:54 Luca Olivetti New Issue
2014-10-21 12:54 Luca Olivetti File Added:
2014-10-21 12:59 Luca Olivetti Note Added: 0078456
2014-10-21 13:58 Reinier Olislagers LazTarget => -
2014-10-21 13:58 Reinier Olislagers Category LCL => Database Components
2014-10-21 13:59 Reinier Olislagers Tag Attached: dbgrid
2014-10-21 13:59 Reinier Olislagers Tag Attached: TPageControl
2014-10-21 15:47 Luca Olivetti File Added:
2014-10-21 15:52 Luca Olivetti Note Added: 0078471
2014-10-21 18:22 Jesus Reyes Assigned To => Jesus Reyes
2014-10-21 18:22 Jesus Reyes Status new => assigned
2014-10-22 16:00 Jesus Reyes Fixed in Revision => 46642
2014-10-22 16:00 Jesus Reyes LazTarget - => 1.4
2014-10-22 16:00 Jesus Reyes Note Added: 0078520
2014-10-22 16:00 Jesus Reyes Status assigned => resolved
2014-10-22 16:00 Jesus Reyes Fixed in Version => 1.3 (SVN)
2014-10-22 16:00 Jesus Reyes Resolution open => fixed
2014-10-22 16:00 Jesus Reyes Target Version => 1.4
2014-10-22 17:30 Luca Olivetti Note Added: 0078529
2014-10-22 17:30 Luca Olivetti Status resolved => closed