View Issue Details

IDProjectCategoryView StatusLast Update
0018660LazarusLCLpublic2017-06-01 11:21
Reportercobines Assigned ToJesus Reyes  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformWin32OSWindows XP 
Product Version0.9.31 (SVN) 
Target Version0.9.30Fixed in Version0.9.31 (SVN) 
Summary0018660: TCustomGrid.ScrollToCell may go into infite loop
DescriptionI have found that my program hangs in ScrollToCell. Unfortunately I cannot reproduce it in a small sample, but I have attached a log when compiled with "dbgGridScroll". From it you can see that Xinc is -1 at some point in the loop, then next turn it is 1, then -1, and again 1, etc. So it adds and substracts value of 1 indefinitely.

This started happening I think after commit 29202, so it is a regression from 0.9.28.

The grid has:
- Flat=True
- FixedCols=0
- FixedRows=1
- ColCount = 5
- RowCount = 21
- Options := [goFixedVertLine, goFixedHorzLine, goTabs, goRowSelect,
              goColSizing, goThumbTracking, goSmoothScroll];

In the program I do:
aGrid.RowCount := 21;
aGrid.Row := 3; <- here it hangs

I'm hoping this might be enough information. Here is the log:

aCol=0 aRow=3 FixHeight=22 CHeight=87 FixWidth=0 CWidth=201
  TL.C=0 TL.R=1 RNew:L=1 T=67 R=251 B=89 Xinc=1 YInc=1 ColOff=0 RowOff=0
  TL.C=1 TL.R=2 RNew:L=-249 T=45 R=1 B=67 Xinc=-1 YInc=0 ColOff=0 RowOff=0
  TL.C=0 TL.R=2 RNew:L=1 T=45 R=251 B=67 Xinc=1 YInc=0 ColOff=0 RowOff=0
  TL.C=1 TL.R=2 RNew:L=-249 T=45 R=1 B=67 Xinc=-1 YInc=0 ColOff=0 RowOff=0
  TL.C=0 TL.R=2 RNew:L=1 T=45 R=251 B=67 Xinc=1 YInc=0 ColOff=0 RowOff=0
  TL.C=1 TL.R=2 RNew:L=-249 T=45 R=1 B=67 Xinc=-1 YInc=0 ColOff=0 RowOff=0
  TL.C=0 TL.R=2 RNew:L=1 T=45 R=251 B=67 Xinc=1 YInc=0 ColOff=0 RowOff=0
  TL.C=1 TL.R=2 RNew:L=-249 T=45 R=1 B=67 Xinc=-1 YInc=0 ColOff=0 RowOff=0
  TL.C=0 TL.R=2 RNew:L=1 T=45 R=251 B=67 Xinc=1 YInc=0 ColOff=0 RowOff=0
  TL.C=1 TL.R=2 RNew:L=-249 T=45 R=1 B=67 Xinc=-1 YInc=0 ColOff=0 RowOff=0

Last two lines continue indefinitely.
TagsNo tags attached.
Fixed in Revision29406
LazTarget0.9.30
Widgetset
Attached Files

Relationships

related to 0031942 resolvedOndrej Pokorny TCustomGrid.ScrollToCell may go into infinite loop (still? again?) 

Activities

cobines

2011-02-02 06:52

reporter   ~0045686

In commit 29202 there was added "+GetBorderWidth" to two places where FGCache.FixedWidth is used, but two other places were not changed. If I do the following the program doesn't hang anymore.

Index: grids.pas
===================================================================
--- grids.pas (revision 29309)
+++ grids.pas (working copy)
@@ -3125,7 +3125,7 @@
     if RNew.Left >= CWidth then
       Xinc := 1 // hidden at the right of clientwidth line
     else
- if (RNew.Left > FGCache.FixedWidth) and
+ if (RNew.Left > FGCache.FixedWidth+GetBorderWidth) and
        (RNew.Left < CWidth) and (CWidth < RNew.Right) then begin
       Xinc := 1; // partially visible at the right
       FGCache.TLColOff := 0; // cancel col-offset for next calcs
@@ -3138,7 +3138,7 @@
     if (RNew.Top >= CHeight) then
       YInc := 1 // hidden at the bottom of clientheight line
     else
- if (RNew.Top > FGCache.FixedHeight) and
+ if (RNew.Top > FGCache.FixedHeight+GetBorderWidth) and
        (RNew.Top < CHeight) and (CHeight < RNew.Bottom) then begin
       Yinc := 1; // partially visible at bottom
       FGCache.TLRowOff := 0; // cancel row-offset for next calcs


Could this be the reason?

Zeljan Rikalo

2011-02-02 08:42

developer   ~0045691

Regression, so 0.9.30

2011-02-06 05:51

 

cobines

2011-02-06 05:52

reporter   ~0045838

I have managed to reproduce with a sample project. It is attached.

Tomasz Wieckowski

2011-02-06 13:43

reporter   ~0045847

I think your patch is correct.
In this case should also include GetBorderWidth (in Flat case).

Jesus Reyes

2011-02-07 08:02

developer   ~0045858

applied thanks

cobines

2011-02-08 06:21

reporter   ~0045888

OK, thanks.

Issue History

Date Modified Username Field Change
2011-02-02 06:27 cobines New Issue
2011-02-02 06:52 cobines Note Added: 0045686
2011-02-02 07:51 Zeljan Rikalo Status new => assigned
2011-02-02 07:51 Zeljan Rikalo Assigned To => Jesus Reyes
2011-02-02 08:42 Zeljan Rikalo LazTarget => 0.9.30
2011-02-02 08:42 Zeljan Rikalo Note Added: 0045691
2011-02-06 05:51 cobines File Added: grid_scrolltocell_hang.zip
2011-02-06 05:52 cobines Note Added: 0045838
2011-02-06 13:43 Tomasz Wieckowski Note Added: 0045847
2011-02-07 08:02 Jesus Reyes Fixed in Revision => 29406
2011-02-07 08:02 Jesus Reyes Status assigned => resolved
2011-02-07 08:02 Jesus Reyes Fixed in Version => 0.9.31 (SVN)
2011-02-07 08:02 Jesus Reyes Resolution open => fixed
2011-02-07 08:02 Jesus Reyes Note Added: 0045858
2011-02-07 08:02 Jesus Reyes Target Version => 0.9.30
2011-02-08 06:21 cobines Status resolved => closed
2011-02-08 06:21 cobines Note Added: 0045888
2017-06-01 11:21 Juha Manninen Relationship added related to 0031942