From: <dav...@us...> - 2009-12-21 04:52:22
|
Revision: 879 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=879&view=rev Author: davidvtaylor Date: 2009-12-21 04:52:06 +0000 (Mon, 21 Dec 2009) Log Message: ----------- * Fix memory leak with TInstantExposer that occurs if the exposer is destroyed with Subject changes pending. The exposer changes are now Undone and the Subject set to Nil in the exposer destructor. * Small optimization in TInstantConnector.GetClientCount to prevent the underlying list from being unnecessarily created when checking if the list is empty. Modified Paths: -------------- trunk/Source/Core/InstantPersistence.pas trunk/Source/Core/InstantPresentation.pas Modified: trunk/Source/Core/InstantPersistence.pas =================================================================== --- trunk/Source/Core/InstantPersistence.pas 2009-12-19 16:27:18 UTC (rev 878) +++ trunk/Source/Core/InstantPersistence.pas 2009-12-21 04:52:06 UTC (rev 879) @@ -8711,7 +8711,10 @@ function TInstantConnector.GetClientCount: Integer; begin - Result := ClientList.Count; + if (assigned(FClientList)) then + Result := FClientList.Count + else + Result := 0; end; function TInstantConnector.GetClientList: TList; Modified: trunk/Source/Core/InstantPresentation.pas =================================================================== --- trunk/Source/Core/InstantPresentation.pas 2009-12-19 16:27:18 UTC (rev 878) +++ trunk/Source/Core/InstantPresentation.pas 2009-12-21 04:52:06 UTC (rev 879) @@ -2545,6 +2545,11 @@ destructor TInstantCustomExposer.Destroy; begin + // Ensure the Exposer is closed. Active will always be False + // for TInstantExposer since the Subject is already set to Nil + // (see TInstantExposer.Destroy for more details). + if Active then + Close; FNotifier.Free; DestroyAccessor; if (csDesigning in ComponentState) and Assigned(DesignModel) then @@ -4413,6 +4418,10 @@ destructor TInstantExposer.Destroy; begin + // Clear the Subject to Undo any pending changes and deactivate the + // Exposer. This prevents TDataSet.Destroy from causing the Subject + // be unexpectedly accessed later in the destruction sequence. + SetSubject(nil); FMasterLink.Free; inherited; end; |