[bug_fixed] Master-detail close/open

Code patches written by our users to solve certain "problems" that were not solved, yet.

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
Edwin
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 17.08.2005, 15:50
Location: Spain

[bug_fixed] Master-detail close/open

Post 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
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
btrewern
Expert Boarder
Expert Boarder
Posts: 193
Joined: 06.10.2005, 18:51

Post 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
zx
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 13.10.2005, 14:05

Post 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.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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.
zx
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 13.10.2005, 14:05

Post 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.
Post Reply