Hello,
i’ve discovered a bug in using clone tables. The problem occurs when i get two tables cloned to one clonesource, then open only one of them, release an instance of the second and then later i release the CloneSource. In attached sample, you can simulate the problem but because there’s not much data in the sample, it doesn’t really ends with an Access Violation even if method of freed object is called.
DASample_CloneRegister.zip (1.5 KB)
As you can see in the “FreeAndNil(LCloneSource)”, it’s TDAMemoryDataset’s method UnregisterAllClients is called and there is still reference to LClone2 instance in his FCloneClientList even if it doesn’t exist anymore.
I think the cause of the problem rests in TDAMemoryDataset.RegisterPermanentClients method which should register just opened clients and should be fixed in this way:
procedure TDAMemoryDataset.RegisterPermanentClients;
var
lClient: TDAMemoryDataset;
i: integer;
llist: TList;
begin
if FClonePermanentClientList <> nil then begin
llist := FClonePermanentClientList.LockList;
try
For I := 0 to llist.Count - 1 do begin
lClient:= TDAMemoryDataset(llist.Items[i]);
if Assigned(lClient) {FIX HERE} and LClient.Active {FIX HERE} then begin
RegisterClient(lClient);
lClient.RegisterPermanentClients;
end;
end;
finally
FClonePermanentClientList.UnlockList;
end;
end;
end;
Regards from Prague,
Jaroslav