Browse Source

Improve progress/abort handling.

Martijn Laan 3 months ago
parent
commit
20e10bb065
1 changed files with 16 additions and 7 deletions
  1. 16 7
      Projects/Src/Setup.Install.pas

+ 16 - 7
Projects/Src/Setup.Install.pas

@@ -3671,6 +3671,12 @@ begin
         FLastReportedProgressMax := FProgressMax;
         FLastReportedProgressMax := FProgressMax;
       end;
       end;
     end;
     end;
+
+    if not Abort and DownloadTemporaryFileOrExtractArchiveProcessMessages then
+      Application.ProcessMessages;
+
+    if Abort then
+      FAborted := True
   end else if Assigned(FOnSimpleDownloadProgress) then begin
   end else if Assigned(FOnSimpleDownloadProgress) then begin
     { Also see Compression.SevenZipDLLDecoder TArchiveExtractToHandleCallback.HandleProgress }
     { Also see Compression.SevenZipDLLDecoder TArchiveExtractToHandleCallback.HandleProgress }
     var Bytes := Progress - FLastReportedProgress;
     var Bytes := Progress - FLastReportedProgress;
@@ -3680,17 +3686,20 @@ begin
         BytesToReport := High(BytesToReport)
         BytesToReport := High(BytesToReport)
       else
       else
         BytesToReport := Bytes;
         BytesToReport := Bytes;
-      FOnSimpleDownloadProgress(BytesToReport);
+      try
+        FOnSimpleDownloadProgress(BytesToReport);
+      except
+        if ExceptObject is EAbort then begin
+          Abort := True;
+          FAborted := True;
+          Break;
+        end else
+          raise;
+      end;
       Dec(Bytes, BytesToReport);
       Dec(Bytes, BytesToReport);
     end;
     end;
     FLastReportedProgress := Progress;
     FLastReportedProgress := Progress;
   end;
   end;
-
-  if not Abort and DownloadTemporaryFileOrExtractArchiveProcessMessages then
-    Application.ProcessMessages;
-
-  if Abort then
-    FAborted := True
 end;
 end;
 
 
 procedure SetUserAgentAndSecureProtocols(const AHTTPClient: THTTPClient);
 procedure SetUserAgentAndSecureProtocols(const AHTTPClient: THTTPClient);