Parcourir la source

Fix ArchiveFindClose breaking handles of other newer and still active searches.

Martijn Laan il y a 3 mois
Parent
commit
3a4ab85dab
1 fichiers modifiés avec 7 ajouts et 3 suppressions
  1. 7 3
      Projects/Src/Compression.SevenZipDLLDecoder.pas

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

@@ -1086,7 +1086,8 @@ end;
 function CheckFindFileHandle(const FindFile: TArchiveFindHandle): Integer;
 function CheckFindFileHandle(const FindFile: TArchiveFindHandle): Integer;
 begin
 begin
   Result := Integer(FindFile);
   Result := Integer(FindFile);
-  if (Result < 0) or (Result >= ArchiveFindStates.Count) then
+  if (Result < 0) or (Result >= ArchiveFindStates.Count) or
+     (ArchiveFindStates[Result].InArchive = nil) then
     InternalError('CheckFindFileHandle failed');
     InternalError('CheckFindFileHandle failed');
 end;
 end;
 
 
@@ -1111,14 +1112,17 @@ end;
 
 
 function ArchiveFindClose(const FindFile: TArchiveFindHandle): Boolean;
 function ArchiveFindClose(const FindFile: TArchiveFindHandle): Boolean;
 begin
 begin
-  ArchiveFindStates.Delete(CheckFindFileHandle(FindFile));
+  const I = CheckFindFileHandle(FindFile);
+  var State := ArchiveFindStates[I];
+  State.InArchive := nil;
+  ArchiveFindStates[I] := State; { This just updates InArchive }
   Result := True;
   Result := True;
 end;
 end;
 
 
 procedure ArchiveFindExtract(const FindFile: TArchiveFindHandle; const DestF: TFile;
 procedure ArchiveFindExtract(const FindFile: TArchiveFindHandle; const DestF: TFile;
   const OnExtractToHandleProgress: TOnExtractToHandleProgress);
   const OnExtractToHandleProgress: TOnExtractToHandleProgress);
 begin
 begin
-  var State := ArchiveFindStates[CheckFindFileHandle(FindFile)];
+  const State = ArchiveFindStates[CheckFindFileHandle(FindFile)];
 
 
   var FindData: TWin32FindData;
   var FindData: TWin32FindData;
   if not State.GetInitialCurrentFindData(FindData) or
   if not State.GetInitialCurrentFindData(FindData) or