Browse Source

Improve wpPreparing a bit more.

Martijn Laan 2 months ago
parent
commit
25d1bb4c9e
2 changed files with 18 additions and 21 deletions
  1. 17 21
      Projects/Src/Setup.WizardForm.pas
  2. 1 0
      whatsnew.htm

+ 17 - 21
Projects/Src/Setup.WizardForm.pas

@@ -1823,6 +1823,17 @@ end;
 
 function TWizardForm.PrepareToInstall(const WizardComponents, WizardTasks: TStringList): String;
 
+  procedure ShowPreparing;
+  begin
+    SetCurPage(wpPreparing);
+    BackButton.Visible := False;
+    NextButton.Visible := False;
+    CancelButton.Enabled := False;
+    if InstallMode = imSilent then
+      WizardForm.Visible := True;
+    WizardForm.Update;
+  end;
+
   function GetClearedDownloadArchivesPage: TDownloadWizardPage;
   begin
     if FDownloadArchivesPage = nil then begin
@@ -1894,6 +1905,7 @@ function TWizardForm.PrepareToInstall(const WizardComponents, WizardTasks: TStri
     end;
 
     if DownloadPage <> nil then begin
+      ShowPreparing;
       DownloadPage.Show;
       try
         var Failed, LastBaseNameOrUrl: String;
@@ -1928,21 +1940,11 @@ function TWizardForm.PrepareToInstall(const WizardComponents, WizardTasks: TStri
           raise Exception.Create(Failed);
       finally
         DownloadPage.Hide;
+        UpdateCurPageButtonState;
       end;
     end;
   end;
 
-  procedure ShowPreparing;
-  begin
-    SetCurPage(wpPreparing);
-    BackButton.Visible := False;
-    NextButton.Visible := False;
-    CancelButton.Enabled := False;
-    if InstallMode = imSilent then
-      WizardForm.Visible := True;
-    WizardForm.Update;
-  end;
-
 var
   CodeNeedsRestart: Boolean;
   Y: Integer;
@@ -1956,12 +1958,7 @@ begin
   PreparingMemo.Visible := False;
 
   try
-    ShowPreparing;
-    try
-      DownloadArchivesToExtract(WizardComponents, WizardTasks);
-    finally
-      UpdateCurPageButtonState;
-    end;
+    DownloadArchivesToExtract(WizardComponents, WizardTasks);
   except
     Result := GetExceptMessage;
   end;
@@ -2319,10 +2316,9 @@ end;
 
 procedure TWizardForm.SetCurPage(const NewPageID: Integer);
 { Changes which page is currently visible }
-var
-  Page: TWizardPage;
 begin
-  Page := PageFromID(NewPageID);
+  const OldCurPageID = CurPageID;
+  const Page = PageFromID(NewPageID);
   FCurPageID := NewPageID;
 
   { Select the page in the notebooks }
@@ -2373,7 +2369,7 @@ begin
   end;
 
   try
-    if CodeRunner <> nil then
+    if (CodeRunner <> nil) and (CurPageID <> OldCurPageID) then
       CodeRunner.RunProcedures('CurPageChanged', [CurPageID], False);
   except
     Application.HandleException(Self);

+ 1 - 0
whatsnew.htm

@@ -216,6 +216,7 @@ Source: "https://jrsoftware.org/download.php/iscrypt.dll?dontcount=1"; DestName:
     <ul>
       <li>Added new <tt>LastBaseNameOrUrl</tt> property to support class <tt>TDownloadWizardPage</tt>. See updated example script <i>CodeDownloadFiles.iss</i> for an example.</li>
       <li>Added new <tt>GetSHA256OfStream</tt> support function.</li>
+      <li><i>Fix:</i> Event function <tt>CurPageChanged</tt> is now always only triggered when the current page actually changes. Before it was called twice in a row for <tt>wpPreparing</tt> when the script had a <tt>PrepareToInstall</tt> event function which returned a non empty string to instruct Setup to stop.</li>
     </ul>
   </li>
   <li>Inno Setup 6.4.3 increased the maximum width of all task dialogs by about 50%, which helps to keep long paths from being truncated with ellipses. It now only does this if the task dialog's content actually contains a path.</li>