OSDN Git Service

SsPlayTimeのインスタンスを参照させた後に、参照されたSsPlayTimeがFreeされると、メモリアクセスエラーを出してしまう問題を修正。
authornaru <bottle@mikage.to>
Sun, 10 Jul 2005 16:25:32 +0000 (16:25 +0000)
committernaru <bottle@mikage.to>
Sun, 10 Jul 2005 16:25:32 +0000 (16:25 +0000)
具体的にはNotificationとFreeNotificationを実装。

sakurasuite/SsPlayTime.pas

index 5382d2d..8804dde 100644 (file)
@@ -92,6 +92,8 @@ type
     procedure CountElements;
     procedure CountCharacterType(const Str: String; out SB, DB,
       SPNum, SPWait: integer);
+    procedure Notification(AComponent: TComponent;
+      Operation: TOperation); override;
   public
     function PlayTime(const Script: String): integer;
     property Counts: TSsPlayTimeCount read FCounts;
@@ -308,6 +310,19 @@ begin
   end;
 end;
 
+procedure TSsPlayTime.Notification(AComponent: TComponent;
+  Operation: TOperation);
+begin
+  inherited;
+  if Operation = opRemove then
+  begin
+    if AComponent = FPlayTimeParams then
+      FPlayTimeParams := nil;
+    if AComponent = FSsParser then
+      FSsParser := nil;
+  end;
+end;
+
 function TSsPlayTime.PlayTime(const Script: String): integer;
 begin
   Result := 0;
@@ -327,11 +342,15 @@ end;
 procedure TSsPlayTime.SetPlayTimeParams(const Value: TSsPlayTimeParams);
 begin
   FPlayTimeParams := Value;
+  if Value <> nil then
+    Value.FreeNotification(self);
 end;
 
 procedure TSsPlayTime.SetSsParser(const Value: TSsParser);
 begin
   FSsParser := Value;
+  if Value <> nil then
+    Value.FreeNotification(self);
 end;
 
 { TSsPlayTimeSpecialChar }
@@ -383,4 +402,3 @@ begin
 end;
 
 end.
\ No newline at end of file