Update of /cvsroot/instantobjects/Source/Core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5634
Modified Files:
InstantPersistence.pas
Log Message:
Fix for the problem that in some situations, where there aren't circular references, an object is incorrectly detached from a References attribute.
[SF BT #1403489]
Index: InstantPersistence.pas
===================================================================
RCS file: /cvsroot/instantobjects/Source/Core/InstantPersistence.pas,v
retrieving revision 1.81
retrieving revision 1.82
diff -C2 -d -r1.81 -r1.82
*** InstantPersistence.pas 4 Jan 2006 04:42:12 -0000 1.81
--- InstantPersistence.pas 12 Jan 2006 01:15:44 -0000 1.82
***************
*** 8226,8229 ****
--- 8226,8252 ----
procedure TInstantObject.FreeCircularReferences;
+
+ function IsInsideCircularReference(const AItem: TInstantComplex):
+ Boolean;
+ var
+ CurrentItem: TInstantComplex;
+ I: Integer;
+ begin
+ Result := AItem.Owner = Self;
+ if not Result and Assigned(AItem.Owner.FRefBy) then
+ for I := 0 to Pred(AItem.Owner.FRefBy.Count) do
+ if AItem.Owner.FRefBy[I] is TInstantComplex then
+ begin
+ CurrentItem := TInstantComplex(AItem.Owner.FRefBy[I]);
+ if CurrentItem.AttributeType in [atReference, atReferences] then
+ begin
+ Result := (AItem.Owner.RefCount = AItem.Owner.FRefBy.Count) and
+ IsInsideCircularReference(CurrentItem);
+ if Result then
+ Exit;
+ end;
+ end;
+ end;
+
var
I: Integer;
***************
*** 8234,8238 ****
with TInstantComplex(FRefBy[I]) do
if (AttributeType in [atReference, atReferences]) and
! (Owner.RefCount = Owner.ReferencedBy.Count) then
// FRefCount will be decremented whenever this
// instance is Detached
--- 8257,8261 ----
with TInstantComplex(FRefBy[I]) do
if (AttributeType in [atReference, atReferences]) and
! IsInsideCircularReference(TInstantComplex(FRefBy[I])) then
// FRefCount will be decremented whenever this
// instance is Detached
|