View Issue Details

IDProjectCategoryView StatusLast Update
0022187LazarusWidgetsetpublic2012-06-08 06:06
ReporterZoran Vučenović Assigned ToZeljan Rikalo  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.1 (SVN) 
Summary0022187: Scrolling throw db records in DBGrid, with arrow keys, in Qt widgetset, skips the last record.
DescriptionWhen you scroll in DBGrid with up and down keys, the last record is skipped in Qt widgetset. The bug does not occur in Win or Gtk2 ws.
Additional InformationI'm uploading the simple application which shows the bug. The application connects to a database named "db_test", change the path as appropriate for you. I use Firebird, but if you don't have FB installed, please make changes in the application to connect to dbms of your choice. You need to create the following table:

create table countries (
  id integer primary key,
  name varchar(30)
);

insert into countries (id, name) values (1, 'Italy');
insert into countries (id, name) values (2, 'Belgium');
insert into countries (id, name) values (3, 'Russia');
insert into countries (id, name) values (4, 'Spain');

The application connects to this table and shows four rows in grid. To reproduce the bug, press down key three times and see that the last row gets skipped and the grid appends new row.

The bug cannot be reproduced with read-only dataset or grid, so take care that Query and Grid have ReadOnly set to False (which is the default).

In my example I use SqlDB components, but I tried with Zeos also and the bug remains! Therefore, this is probably Qt widgetset bug, not SqlDB bug.
TagsNo tags attached.
Fixed in Revision37534
LazTarget1.0
WidgetsetQT
Attached Files

Relationships

related to 0016255 closedZeljan Rikalo QT: editor window does not move to cursor position after startup 
related to 0019687 closedZeljan Rikalo ScrollBar does not function in StringGrid. 
has duplicate 0022188 closedZeljan Rikalo Scrolling throw db records in DBGrid, with arrow keys, in Qt widgetset, skips the last record. 

Activities

2012-06-03 22:10

 

db_test.zip (129,773 bytes)

Zeljan Rikalo

2012-06-04 05:52

developer   ~0060240

@Zoran, can you provide example based on sqlite or dbf ? I don't have firebird (just installed libfbembed but cannot connect).

Zeljan Rikalo

2012-06-04 06:55

developer   ~0060244

not needed, I've added pgsql connection

2012-06-04 09:49

 

db_test_SQLite.zip (129,779 bytes)

Zoran Vučenović

2012-06-04 09:56

developer   ~0060252

Last edited: 2012-06-04 09:57

Thank you, Željan. Anyway, I uploaded the aplication based on SQLite. Now, there is also a db file packed inside.

Today I have also tested with QT in Windows (yesterday I tested QT only in Linux) and the same bug occurs.

Zeljan Rikalo

2012-06-05 18:50

developer   ~0060297

@Zoran, yes, I suppose that all qtlcl platforms are affected by this,but this thing need little bit more spare time to find out what exactly is going on - and my spare time is critical atm :) . I've tried just to compare SetScrollInfo of gtk2 and qt and found differences in nPos when doing last step - so it's probably good point to start debugging. Have you tested with pure win32 ? It works ok there ?

Zoran Vučenović

2012-06-06 09:43

developer   ~0060305

Yes, I tested with win32/64 widgetset and it works correctly there, as well as with Gtk2. The bug occurs with QT only.

2012-06-06 15:03

 

qtscrollbarproblemfix.diff (2,386 bytes)   
Index: lcl/interfaces/qt/qtwinapi.inc
===================================================================
--- lcl/interfaces/qt/qtwinapi.inc	(revision 37515)
+++ lcl/interfaces/qt/qtwinapi.inc	(working copy)
@@ -5938,16 +5938,13 @@
   function UpdateScrollInfo: Integer;
   var
     iReCountMax: Integer;
-    SBUpdatesCount: Integer;
     i: Integer;
     WheelLines: Integer;
   begin
     Result := 0;
-    SBUpdatesCount := 0;
 
     if (ScrollInfo.FMask and SIF_RANGE) <> 0 then
     begin
-      inc(SBUpdatesCount);
       ScrollBar.setMinimum(ScrollInfo.nMin);
 
       // we must recount ScrollBar.Max since invalid value raises AV
@@ -5963,7 +5960,6 @@
       // segfaults if we don't check Enabled property
       if ScrollBar.getEnabled then
       begin
-        inc(SBUpdatesCount);
         ScrollBar.setPageStep(ScrollInfo.nPage);
         WheelLines := QApplication_wheelScrollLines();
         with Scrollbar do
@@ -5979,30 +5975,18 @@
 
     if (ScrollInfo.FMask and SIF_POS) <> 0 then
     begin
-      inc(SBUpdatesCount);
+      if not (ScrollBar.getTracking and ScrollBar.getSliderDown) then
+      begin
+        if (ScrollInfo.nPos < ScrollBar.getMin) then
+          ScrollInfo.nPos := ScrollBar.getMin
+        else
+        if (ScrollInfo.nPos > ScrollBar.getMax) then
+          ScrollInfo.nPos := ScrollBar.getMax;
 
-      if SBUpdatesCount = 1 then
-        ScrollBar.BeginUpdate;
-      try
-        if not (ScrollBar.getTracking and ScrollBar.getSliderDown) then
-        begin
-          {do not setValue() if values are equal, since it calls
-           signalValueChanged() which sends unneeded LM_SCROLL msgs }
-          if (ScrollBar.getValue = ScrollInfo.nPos) then
-            SBUpdatesCount := 0;
-
-          if (ScrollInfo.nPos < ScrollBar.getMin) then
-            ScrollInfo.nPos := ScrollBar.getMin
-          else
-          if (ScrollInfo.nPos > ScrollBar.getMax) then
-            ScrollInfo.nPos := ScrollBar.getMax;
-
-          if (SBUpdatesCount > 0) then
-            ScrollBar.setValue(ScrollInfo.nPos);
-        end;
-      finally
-        if ScrollBar.InUpdate then
-          ScrollBar.EndUpdate;
+        // if (SBUpdatesCount > 0) then
+        if (ScrollBar.getSliderPosition <> ScrollInfo.nPos) then
+          ScrollBar.setSliderPosition(ScrollInfo.nPos);
+        // setValue(ScrollInfo.nPos);
       end;
     end;
 
qtscrollbarproblemfix.diff (2,386 bytes)   

Zeljan Rikalo

2012-06-06 15:05

developer   ~0060314

@Zoran, can you test with provided patch ? It works ok for me with it, but haven't tested other aspects of such change so it won't be applied soon.
Must test all scenarios with all tcustomcontrol scrollable controls (which uses SetScrollInfo).

Zoran Vučenović

2012-06-06 22:57

developer   ~0060322

Thank you. Works correctly when I applied this patch.

Zeljan Rikalo

2012-06-07 07:45

developer   ~0060329

Yes, it seems that it's correct with other controls too.

Zeljan Rikalo

2012-06-07 07:47

developer   ~0060330

Please test and close if ok.

Zoran Vučenović

2012-06-08 06:06

developer   ~0060360

It seems that the problem is solved in Linux, but not in Windows! The bug seems to be still present in Windows with QT ws. :(

Issue History

Date Modified Username Field Change
2012-06-03 22:10 Zoran Vučenović New Issue
2012-06-03 22:10 Zoran Vučenović File Added: db_test.zip
2012-06-03 22:10 Zoran Vučenović Widgetset => QT
2012-06-04 05:40 Zeljan Rikalo Relationship added has duplicate 0022188
2012-06-04 05:40 Zeljan Rikalo Status new => assigned
2012-06-04 05:40 Zeljan Rikalo Assigned To => Zeljan Rikalo
2012-06-04 05:52 Zeljan Rikalo LazTarget => -
2012-06-04 05:52 Zeljan Rikalo Note Added: 0060240
2012-06-04 05:52 Zeljan Rikalo Status assigned => feedback
2012-06-04 06:55 Zeljan Rikalo Note Added: 0060244
2012-06-04 09:49 Zoran Vučenović File Added: db_test_SQLite.zip
2012-06-04 09:56 Zoran Vučenović Note Added: 0060252
2012-06-04 09:57 Zoran Vučenović Note Edited: 0060252
2012-06-05 18:50 Zeljan Rikalo Note Added: 0060297
2012-06-06 09:43 Zoran Vučenović Note Added: 0060305
2012-06-06 15:03 Zeljan Rikalo File Added: qtscrollbarproblemfix.diff
2012-06-06 15:05 Zeljan Rikalo Note Added: 0060314
2012-06-06 15:05 Zeljan Rikalo Status feedback => confirmed
2012-06-06 15:32 Zeljan Rikalo Relationship added related to 0016255
2012-06-06 15:32 Zeljan Rikalo Relationship added related to 0019687
2012-06-06 22:57 Zoran Vučenović Note Added: 0060322
2012-06-07 07:45 Zeljan Rikalo Note Added: 0060329
2012-06-07 07:47 Zeljan Rikalo Fixed in Revision => 37534
2012-06-07 07:47 Zeljan Rikalo LazTarget - => 1.0
2012-06-07 07:47 Zeljan Rikalo Status confirmed => resolved
2012-06-07 07:47 Zeljan Rikalo Resolution open => fixed
2012-06-07 07:47 Zeljan Rikalo Note Added: 0060330
2012-06-08 06:06 Zoran Vučenović Note Added: 0060360