Page 1 of 1

[bug_fixed] Master-detail close/open

Posted: 25.02.2007, 03:32
by Edwin
Hello,

When I change something in a Master Dataset (TZQuery), the focus of the DBGrid of its Detail Dataset always jumps to the first record. This happens because the Detail Dataset closes and opens when its Master Dataset changes. Could you improve this behaviour by changing this in the unit ZAbstractRODataset.pas:

procedure TZAbstractRODataset.RefreshParams;
var
DataSet: TDataSet;
begin
DisableControls;
try
if FDataLink.DataSource <> nil then
begin
DataSet := FDataLink.DataSource.DataSet;
if DataSet <> nil then
//if DataSet.Active and (DataSet.State <> dsSetKey) then <- old
if DataSet.Active and not (DataSet.State in [dsSetKey, dsEdit, dsInsert]) then // <- new
begin
Close;
Open;
end;
end;
finally
EnableControls;
end;
end;

Please test this code.
Thanks,

Edwin

Posted: 07.03.2007, 12:12
by mdaems
Hoi Edwin,

Just checked your proposal. It does not break the test suite and looks logical. I hope nobody else gets trouble using master-detail queries.
Committed to testing branch (Rev. 225).

Mark

Posted: 07.03.2007, 16:54
by btrewern
Thanks Edwin!!

I came across this same problem about a year ago and spent ~2 days trying to work out how to fix it.

Sometimes you can't see the wood for the trees.

Regards,

Ben

Posted: 29.05.2007, 13:18
by zx
greetings.
there is one more issue one can think about a matter mentioned.

it is a place where

Code: Select all

begin 
Close; 
Open; 
end;
is done. the thing is that when you do not create fields in dataset manually, they are being created when dataset opens and destroyed when it closes.

and some visual data-aware components (developer express ones, for instance) do not notice that fields they were binded to were re-created. It happens that way if Close\Open sequence happens in Disable\enable Controls block.

this leads to lost pointers and exceptions.

to solve this problems i manually change close\open sequence with REFRESH statement each time ZEOS DBO is updated to new version.

i've reported this for several times, but...

if respected developers would be so nice to test this micro-patch and add it to repository it would save me some time :)

thanx for attention.

Posted: 29.05.2007, 23:19
by mdaems
@zx,

I hope you're sure this works without side effects. Sounds logical and the test suite doesn't fail. So I committed it. (Rev 252)
Can you please log future bugs to the bug tracker? That what that thing is made for. You can find it here: http://zeosbugs.firmos.at/
When it's a new feature you invented it's welcome to the User Patches Forum.

@edwin : can you please test your code again with this patch? Just to make sure we're not doing stupid things.

Posted: 30.05.2007, 05:53
by zx
mdaems wrote: I hope you're sure this works without side effects.
well. everything I can tell is that there were exceptions like I described before patch and they disappear after it.

That certainly does not mean I've covered every situation possible.