OSDN Git Service

終了時に確実にUnloadが呼ばれるための処理追加
authornaru <bottle@mikage.to>
Mon, 11 Jul 2005 10:58:01 +0000 (10:58 +0000)
committernaru <bottle@mikage.to>
Mon, 11 Jul 2005 10:58:01 +0000 (10:58 +0000)
bottleclient/Plugins.pas

index 9f0f612..2ad0cf9 100644 (file)
@@ -75,12 +75,14 @@ type
   TSppImplementation = class(TObject)
   private
     FOwner: TSppPlugin;
+    FLoaded: Boolean;
   public
     constructor Create(Owner: TSppPlugin); virtual;
-    procedure Load; virtual; abstract;
+    destructor Destroy; override;
+    procedure Load; virtual;
     function GetImage(const Ghost: String;
       Surface: integer; Scope: TScope): TSppImage; virtual; abstract;
-    procedure Unload; virtual; abstract;
+    procedure Unload; virtual;
     property Owner: TSppPlugin read FOwner;
     procedure Configure; virtual; abstract;
   end;
@@ -185,6 +187,23 @@ begin
   FOwner := Owner;
 end;
 
+destructor TSppImplementation.Destroy;
+begin
+  if FLoaded then
+    Unload;
+  inherited;
+end;
+
+procedure TSppImplementation.Load;
+begin
+  FLoaded := true;
+end;
+
+procedure TSppImplementation.Unload;
+begin
+  FLoaded := false;
+end;
+
 { TSppImage }
 
 constructor TSppImage.Create;
@@ -350,14 +369,14 @@ end;
 
 procedure TSppImplementation1.Load;
 begin
-  inherited;
   FSppLoad(PChar(ExtractFilePath(Owner.ModuleName)));
+  inherited Load;
 end;
 
 procedure TSppImplementation1.Unload;
 begin
-  inherited;
   FSppUnload;
+  inherited Unload;
 end;
 
 end.