Cursor jumps in detail DS on master refresh (w/fix)

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
Post Reply
Fr0sT
Zeos Dev Team
Zeos Dev Team
Posts: 280
Joined: 08.05.2014, 12:08

Cursor jumps in detail DS on master refresh (w/fix)

Post by Fr0sT »

Under some conditions cursor for detail DS may jump on master refresh.
I catched it with the following scheme:
Master: TZTable, Detail: TZQuery, DetailGrid: TDBGridEh (a grid from EhLib, version 3.6) connected to Detail.
Now if we execute Master.Refresh, the cursor for Detail jumps downward. This happens only with TDBGridEh attached while stock Delphi 7 grid is OK. But probably other custom grids produce this issue as well. I presume so because I see many quite odd manipulations with TZAbstractRODataset.CurrentRow property in Zeos while this property is used to move the cursor on refresh.
Luckily I managed to find an extremely trivial solution:
method

Code: Select all

TZAbstractRODataset.RereadRows
line

Code: Select all

if (CurrentRow > 0) and (CurrentRow <= CurrentRows.Count) and
add

Code: Select all

UpdateCursorPos;
before the line

So before refreshing we force CurrentRow to correspond the cursor.

Talking generally, I'd advice to redesign usage of CurrentRow or at least correct it with UpdateCursorPos every time it is used as "index of a record the cursor points at".
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Cursor jumps in detail DS on master refresh (w/fix)

Post by EgonHugeist »

Did answer your ticket..
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
RaThek
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 22.01.2014, 16:56

Re: Cursor jumps in detail DS on master refresh (w/fix)

Post by RaThek »

FrOsT is right. I had problem with moving cursor while using ApplyUpdates. After adding UpdateCursorPos in TZAbstractDataset.ApplyUpdates procedure problem is gone.
Without this line CurrentRow in TZAbstractRODataset.GetRecord always pointed to the last record.

Updated part:

Code: Select all

UpdateCursorPos;
if not (State in [dsInactive]) then
Resync([]);
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Cursor jumps in detail DS on master refresh (w/fix)

Post by EgonHugeist »

The fix is already applied..
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
RaThek
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 22.01.2014, 16:56

Re: Cursor jumps in detail DS on master refresh (w/fix)

Post by RaThek »

Already? In 3438 it wasn't working as expected...
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Cursor jumps in detail DS on master refresh (w/fix)

Post by EgonHugeist »

Current code is:

Code: Select all

procedure TZAbstractRODataset.RereadRows;
var
  I: NativeUInt;
  RowNo: NativeInt;
begin
  if not (State in [dsInactive]) and not IsUniDirectional then
  begin
    UpdateCursorPos; //see http://sourceforge.net/p/zeoslib/tickets/89/
    if (CurrentRow > 0) and (CurrentRow <= CurrentRows.Count) and
       (CurrentRows.Count > 0) then
      RowNo := {%H-}NativeInt(CurrentRows[CurrentRow - 1])
    else
      RowNo := -1;
    CurrentRows.Clear;

    for I := 1 to FetchCount do
      if FilterRow(I) then
        CurrentRows.Add({%H-}Pointer(I));

    CurrentRow := CurrentRows.IndexOf({%H-}Pointer(RowNo)) + 1;
    CurrentRow := Min(Max(1, CurrentRow), CurrentRows.Count);

    if FSortedFields <> '' then
      InternalSort
    else
      Resync([]);
  end;
end;
Do i overlook something?
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
RaThek
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 22.01.2014, 16:56

Re: Cursor jumps in detail DS on master refresh (w/fix)

Post by RaThek »

Seems we missunderstood. I'm talking about TZAbstractDataset.ApplyUpdates.
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Cursor jumps in detail DS on master refresh (w/fix)

Post by EgonHugeist »

Yep i did missunderstoud you!

Patch done R3521 \testing-7.2.
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Post Reply