Ver código fonte

Call Abort immediately when OnExtractionProgress returns False.

Previously, if extraction completed while OnExtractionProgress was running
or soon after, then the function would succeed and not raise EAbort
despite the False result. This was confusing because it made it look like
returning False was having no effect. It would also be problematic if the
user's code performed some sort of teardown action prior to returning
False, but then no exception was raised and execution continued normally.
Jordan Russell 2 meses atrás
pai
commit
a54bb14ba2
1 arquivos alterados com 3 adições e 12 exclusões
  1. 3 12
      Projects/Src/Compression.SevenZipDLLDecoder.pas

+ 3 - 12
Projects/Src/Compression.SevenZipDLLDecoder.pas

@@ -674,9 +674,7 @@ begin
     else
     else
       Msg := FResult.SavedFatalException.ClassName;
       Msg := FResult.SavedFatalException.ClassName;
     InternalErrorFmt('Worker thread terminated unexpectedly with exception: %s', [Msg]);
     InternalErrorFmt('Worker thread terminated unexpectedly with exception: %s', [Msg]);
-  end else if FResult.Res = E_ABORT then
-    Abort
-  else begin
+  end else begin
     var OpRes := FResult.OpRes;
     var OpRes := FResult.OpRes;
     if OpRes <> kOK then
     if OpRes <> kOK then
       BadOperationResultError(OpRes)
       BadOperationResultError(OpRes)
@@ -834,22 +832,15 @@ begin
     System.TMonitor.Exit(FLock);
     System.TMonitor.Exit(FLock);
   end;
   end;
 
 
-  var Abort := FAbort;
-  if Abort then
-    Exit;
-
   if (CurrentPath <> '') and Assigned(FOnExtractionProgress) then begin
   if (CurrentPath <> '') and Assigned(FOnExtractionProgress) then begin
     { Calls to HandleProgress are already throttled so here we don't have to worry
     { Calls to HandleProgress are already throttled so here we don't have to worry
       about calling the script to often }
       about calling the script to often }
     if not FOnExtractionProgress(FExtractedArchiveName, CurrentPath, Progress, ProgressMax) then
     if not FOnExtractionProgress(FExtractedArchiveName, CurrentPath, Progress, ProgressMax) then
-      Abort := True;
+      Abort;
   end;
   end;
 
 
-  if not Abort and DownloadTemporaryFileOrExtractArchiveProcessMessages then
+  if DownloadTemporaryFileOrExtractArchiveProcessMessages then
     Application.ProcessMessages;
     Application.ProcessMessages;
-
-  if Abort then
-    FAbort := Abort; { Atomic so no lock }
 end;
 end;
 
 
 { TArchiveExtractToHandleCallback }
 { TArchiveExtractToHandleCallback }