Procházet zdrojové kódy

Merge branch 'main' into tscriptfunc

Martijn Laan před 10 měsíci
rodič
revize
9557730439

+ 2 - 0
Components/NewTabSet.pas

@@ -198,7 +198,9 @@ end;
 destructor TNewTabSet.Destroy;
 destructor TNewTabSet.Destroy;
 begin
 begin
   UpdateThemeData(False);
   UpdateThemeData(False);
+  FHints.Free;
   FTabs.Free;
   FTabs.Free;
+  FCloseButtons.Free;
   inherited;
   inherited;
 end;
 end;
 
 

+ 1 - 1
ISHelp/isxfunc.xml

@@ -1849,7 +1849,7 @@ end;</pre>
 <p>The archive must not be encrypted.</p>
 <p>The archive must not be encrypted.</p>
 <p>Set OnExtractionProgress to a function to be informed of progress, or <tt>nil</tt> otherwise.</p></description>
 <p>Set OnExtractionProgress to a function to be informed of progress, or <tt>nil</tt> otherwise.</p></description>
         <remarks><p>TOnExtractionProgress is defined as:</p>
         <remarks><p>TOnExtractionProgress is defined as:</p>
-<p><tt>TOnExtractionProgress = function(const ArchiveName, FileName: string; const Progress, ProgressMax: Int64): Boolean;</tt></p>
+<p><tt>TOnExtractionProgress = function(const ArchiveName, FileName: String; const Progress, ProgressMax: Int64): Boolean;</tt></p>
 <p>Return True to allow the extraction to continue, False otherwise.</p>
 <p>Return True to allow the extraction to continue, False otherwise.</p>
 <p><tt>Extract7ZipArchive</tt> uses an embedded version of the &quot;7z ANSI-C Decoder&quot; from the LZMA SDK by Igor Pavlov, as-is, except that Unicode support and error messages were improved and that it outputs memory requirements.</p>
 <p><tt>Extract7ZipArchive</tt> uses an embedded version of the &quot;7z ANSI-C Decoder&quot; from the LZMA SDK by Igor Pavlov, as-is, except that Unicode support and error messages were improved and that it outputs memory requirements.</p>
 <p>All output of the decoder is logged if logging is enabled, including error messages but excluding empty lines.</p>
 <p>All output of the decoder is logged if logging is enabled, including error messages but excluding empty lines.</p>

+ 2 - 2
Projects/Src/Compiler.ScriptFunc.pas

@@ -140,8 +140,8 @@ begin
     '  SuiteMask: Word;' +
     '  SuiteMask: Word;' +
     'end');
     'end');
 
 
-  RegisterType('TOnDownloadProgress', 'function(const Url, FileName: string; const Progress, ProgressMax: Int64): Boolean;');
-  RegisterType('TOnExtractionProgress', 'function(const ArchiveName, FileName: string; const Progress, ProgressMax: Int64): Boolean;');
+  RegisterType('TOnDownloadProgress', 'function(const Url, FileName: String; const Progress, ProgressMax: Int64): Boolean;');
+  RegisterType('TOnExtractionProgress', 'function(const ArchiveName, FileName: String; const Progress, ProgressMax: Int64): Boolean;');
   RegisterType('TOnLog', 'procedure(const S: String; const Error, FirstLine: Boolean);');
   RegisterType('TOnLog', 'procedure(const S: String; const Error, FirstLine: Boolean);');
 
 
   for var ScriptFuncTable in ScriptFuncTables do
   for var ScriptFuncTable in ScriptFuncTables do

+ 28 - 11
Projects/Src/IDE.MainForm.pas

@@ -473,6 +473,7 @@ type
     FBuildAnimationFrame: Cardinal;
     FBuildAnimationFrame: Cardinal;
     FLastAnimationTick: DWORD;
     FLastAnimationTick: DWORD;
     FProgress, FProgressMax: Cardinal;
     FProgress, FProgressMax: Cardinal;
+    FTaskbarProgressValue: Cardinal;
     FProgressThemeData: HTHEME;
     FProgressThemeData: HTHEME;
     FMenuThemeData: HTHEME;
     FMenuThemeData: HTHEME;
     FToolbarThemeData: HTHEME;
     FToolbarThemeData: HTHEME;
@@ -2312,6 +2313,7 @@ begin
     FBuildAnimationFrame := 0;
     FBuildAnimationFrame := 0;
     FProgress := 0;
     FProgress := 0;
     FProgressMax := 0;
     FProgressMax := 0;
+    FTaskbarProgressValue := 0;
 
 
     FActiveMemo.CancelAutoCompleteAndCallTip;
     FActiveMemo.CancelAutoCompleteAndCallTip;
     FActiveMemo.Cursor := crAppStart;
     FActiveMemo.Cursor := crAppStart;
@@ -7108,16 +7110,15 @@ end;
 procedure TMainForm.UpdateCompileStatusPanels(const AProgress,
 procedure TMainForm.UpdateCompileStatusPanels(const AProgress,
   AProgressMax: Cardinal; const ASecondsRemaining: Integer;
   AProgressMax: Cardinal; const ASecondsRemaining: Integer;
   const ABytesCompressedPerSecond: Cardinal);
   const ABytesCompressedPerSecond: Cardinal);
-var
-  T: DWORD;
 begin
 begin
-  { Icon panel }
-  T := GetTickCount;
-  if Cardinal(T - FLastAnimationTick) >= Cardinal(500) then begin
-    FLastAnimationTick := T;
+  var CurTick := GetTickCount;
+  var LastTick := FLastAnimationTick;
+  FLastAnimationTick := CurTick;
+
+  { Icon and text panels - updated every 500ms }
+  if CurTick div 500 <> LastTick div 500 then begin
     InvalidateStatusPanel(spCompileIcon);
     InvalidateStatusPanel(spCompileIcon);
     FBuildAnimationFrame := (FBuildAnimationFrame + 1) mod 4;
     FBuildAnimationFrame := (FBuildAnimationFrame + 1) mod 4;
-    { Also update the status text twice a second }
     if ASecondsRemaining >= 0 then
     if ASecondsRemaining >= 0 then
       StatusBar.Panels[spExtraStatus].Text := Format(
       StatusBar.Panels[spExtraStatus].Text := Format(
         ' Estimated time remaining: %.2d%s%.2d%s%.2d     Average KB/sec: %.0n',
         ' Estimated time remaining: %.2d%s%.2d%s%.2d     Average KB/sec: %.0n',
@@ -7128,13 +7129,29 @@ begin
       StatusBar.Panels[spExtraStatus].Text := '';
       StatusBar.Panels[spExtraStatus].Text := '';
   end;
   end;
 
 
-  { Progress panel and taskbar progress bar }
-  if (FProgress <> AProgress) or
-     (FProgressMax <> AProgressMax) then begin
+  { Progress panel and taskbar progress bar - updated every 100ms }
+  if (CurTick div 100 <> LastTick div 100) and
+     ((FProgress <> AProgress) or (FProgressMax <> AProgressMax)) then begin
     FProgress := AProgress;
     FProgress := AProgress;
     FProgressMax := AProgressMax;
     FProgressMax := AProgressMax;
     InvalidateStatusPanel(spCompileProgress);
     InvalidateStatusPanel(spCompileProgress);
-    SetAppTaskbarProgressValue(AProgress, AProgressMax);
+
+    { The taskbar progress updates are slow (on Windows 11). Limiting the
+      range to 64 instead of 1024 improved compression KB/sec by about 4%
+      (9000 to 9400) when the rate limit above is disabled. }
+    var NewValue: Cardinal := 1;  { must be at least 1 for progress bar to show }
+    if AProgressMax > 0 then begin
+      { Not using MulDiv here to avoid rounding up }
+      NewValue := (AProgress * 64) div AProgressMax;
+      if NewValue = 0 then
+        NewValue := 1;
+    end;
+    { Don't call the function if the value hasn't changed, just in case there's
+      a performance penalty. (There doesn't appear to be on Windows 11.) }
+    if FTaskbarProgressValue <> NewValue then begin
+      FTaskbarProgressValue := NewValue;
+      SetAppTaskbarProgressValue(NewValue, 64);
+    end;
   end;
   end;
 end;
 end;