Page 1 of 1

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

Posted: 01.08.2014, 15:38
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".

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

Posted: 02.08.2014, 17:12
by EgonHugeist
Did answer your ticket..

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

Posted: 04.11.2014, 19:36
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([]);

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

Posted: 05.11.2014, 16:41
by EgonHugeist
The fix is already applied..

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

Posted: 19.11.2014, 07:59
by RaThek
Already? In 3438 it wasn't working as expected...

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

Posted: 19.11.2014, 11:37
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?

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

Posted: 21.11.2014, 20:15
by RaThek
Seems we missunderstood. I'm talking about TZAbstractDataset.ApplyUpdates.

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

Posted: 29.11.2014, 17:57
by EgonHugeist
Yep i did missunderstoud you!

Patch done R3521 \testing-7.2.