浏览代码

Bug fix: Failure on exit

When closing after transfer on command-line (/upload), the PngImageList finalization section is run before DoneApplication. When the DoneApplication is run later, it tried to release MethodPatches again.

We prevent that by explicitly destroying all TPngImageList's explicitly (indirectly via destroying all data modules)

Source commit: ad6096132d74694eb0a45b4cbc15b1132c3c6384
Martin Prikryl 9 年之前
父节点
当前提交
4cec224420
共有 3 个文件被更改,包括 20 次插入3 次删除
  1. 18 3
      source/forms/Animations.cpp
  2. 1 0
      source/windows/WinInterface.h
  3. 1 0
      source/windows/WinMain.cpp

+ 18 - 3
source/forms/Animations.cpp

@@ -2,7 +2,7 @@
 #include <vcl.h>
 #pragma hdrstop
 
-#include "Global.h"
+#include "Common.h"
 #include "Animations.h"
 #include "Animations96.h"
 #include "Animations120.h"
@@ -36,6 +36,14 @@ TAnimationsModule * __fastcall GetAnimationsModule()
   return AnimationsModule;
 }
 //---------------------------------------------------------------------------
+void __fastcall ReleaseAnimationsModule()
+{
+  if (AnimationsModule != NULL)
+  {
+    SAFE_DESTROY(AnimationsModule);
+  }
+}
+//---------------------------------------------------------------------------
 __fastcall TAnimationsModule::TAnimationsModule(TComponent * Owner)
   : TDataModule(Owner)
 {
@@ -58,8 +66,15 @@ __fastcall TAnimationsModule::TAnimationsModule(TComponent * Owner)
     ScaledModule = new TAnimations96Module(Application);
   }
 
-  // Not really necessary as we never acccess AnimationImages by name
-  CopyDataModule(this, ScaledModule);
+  try
+  {
+    // Not really necessary as we never acccess AnimationImages by name
+    CopyDataModule(this, ScaledModule);
+  }
+  __finally
+  {
+    delete ScaledModule;
+  }
 
   AnimationImages = DebugNotNull(dynamic_cast<TPngImageList *>(FindComponent(AnimationImages->Name)));
 }

+ 1 - 0
source/windows/WinInterface.h

@@ -461,6 +461,7 @@ bool __fastcall IsCustomShortCut(TShortCut ShortCut);
 
 class TAnimationsModule;
 TAnimationsModule * __fastcall GetAnimationsModule();
+void __fastcall ReleaseAnimationsModule();
 
 #ifdef _DEBUG
 void __fastcall ForceTracing();

+ 1 - 0
source/windows/WinMain.cpp

@@ -1017,6 +1017,7 @@ int __fastcall Execute()
   {
     delete NonVisualDataModule;
     NonVisualDataModule = NULL;
+    ReleaseAnimationsModule();
     delete GlyphsModule;
     GlyphsModule = NULL;
     TTerminalManager::DestroyInstance();