浏览代码

Close update dialog after failure

Source commit: 492f40b488ba31fc97b70615c891e2935f147ec7
Martin Prikryl 9 年之前
父节点
当前提交
f758a7de86
共有 1 个文件被更改,包括 13 次插入2 次删除
  1. 13 2
      source/windows/Setup.cpp

+ 13 - 2
source/windows/Setup.cpp

@@ -1173,6 +1173,8 @@ public:
 
   bool __fastcall CancelDownload();
 
+  __property bool Done = { read = FDone };
+
 protected:
   virtual void __fastcall Execute();
   void __fastcall UpdateDownloaded();
@@ -1189,6 +1191,7 @@ private:
   std::unique_ptr<Exception> FException;
   std::unique_ptr<THttp> FHttp;
   TUpdatesConfiguration FUpdates;
+  bool FDone;
 };
 //---------------------------------------------------------------------------
 __fastcall TUpdateDownloadThread::TUpdateDownloadThread(TProgressBar * ProgressBar) :
@@ -1200,6 +1203,7 @@ __fastcall TUpdateDownloadThread::TUpdateDownloadThread(TProgressBar * ProgressB
   FProgressBar = ProgressBar;
   // cache to prevent concurrency
   FUpdates = WinConfiguration->Updates;
+  FDone = false;
 }
 //---------------------------------------------------------------------------
 __fastcall TUpdateDownloadThread::~TUpdateDownloadThread()
@@ -1271,6 +1275,7 @@ void __fastcall TUpdateDownloadThread::Execute()
     Synchronize(ShowException);
   }
 
+  FDone = true;
   Synchronize(CancelForm);
 }
 //---------------------------------------------------------------------------
@@ -1418,9 +1423,15 @@ public:
 static void __fastcall DownloadClose(void * /*Data*/, TObject * Sender, TCloseAction & Action)
 {
   TUpdateDownloadData * UpdateDownloadData = TUpdateDownloadData::Retrieve(Sender);
-  if (UpdateDownloadData->Thread->CancelDownload())
+  // If the form was closed by CancelForm at the end of the thread, do nothing
+  if (!UpdateDownloadData->Thread->Done)
   {
-    Action = caNone;
+    // Otherwise the form is closing because X was clicked (or maybe Cancel).
+    // May this should actually call CancelClicked?
+    if (UpdateDownloadData->Thread->CancelDownload())
+    {
+      Action = caNone;
+    }
   }
 }
 //---------------------------------------------------------------------------