Bladeren bron

Libraries: added disposables in TApplicationForm

Herman Schoenfeld 7 jaren geleden
bovenliggende
commit
1aa866c22b
1 gewijzigde bestanden met toevoegingen van 10 en 1 verwijderingen
  1. 10 1
      src/libraries/sphere10/UCommon.UI.pas

+ 10 - 1
src/libraries/sphere10/UCommon.UI.pas

@@ -17,7 +17,9 @@ unit UCommon.UI;
 interface
 
 uses
-  Classes, SysUtils, Forms, Controls,ExtCtrls,  FGL, Graphics, Generics.Collections, Generics.Defaults, syncobjs;
+  Classes, SysUtils, Forms, Controls,ExtCtrls,
+  FGL, Graphics, Generics.Collections, Generics.Defaults, syncobjs,
+  UMemory;
 
 type
   TApplicationForm = class(TForm)
@@ -26,6 +28,7 @@ type
       FActivateFirstTime : TNotifyEvent;
       FDestroyed : TNotifyEvent;
       FCloseAction : TCloseAction;
+      FDisposables : TDisposables;
       procedure NotifyActivateFirstTime;
       procedure NotifyDestroyed;
     protected
@@ -42,6 +45,7 @@ type
       property OnDestroyed : TNotifyEvent read FDestroyed write FDestroyed;
     public
       property ActivationCount : UInt32 read FActivatedCount;
+      function AutoDispose(AObject : TObject) : TObject;
   end;
 
   { TWinControlHelper }
@@ -104,6 +108,11 @@ procedure TApplicationForm.DoDestroyed;
 begin;
 end;
 
+function TApplicationform.AutoDispose(AObject : TObject) : TObject;
+begin
+  Result := FDisposables.AddObject(AObject);
+end;
+
 procedure TApplicationForm.NotifyActivateFirstTime;
 begin
   ActivateFirstTime;