瀏覽代碼

Prevent recursive directory tree updates when changes happen too frequently

Attempt to fix Bug 2024
https://winscp.net/tracker/2024

Source commit: 6e6484247358362df350cc5909f7cc28248f461a
Martin Prikryl 4 年之前
父節點
當前提交
fc8df43a35
共有 1 個文件被更改,包括 17 次插入9 次删除
  1. 17 9
      source/packages/filemng/DriveView.pas

+ 17 - 9
source/packages/filemng/DriveView.pas

@@ -2038,16 +2038,24 @@ begin
     begin
       if DriveStatusPair.Value.ChangeTimer = Sender then
       begin
-        with DriveStatusPair.Value.ChangeTimer do
-        begin
-          Interval := 0;
-          Enabled := False;
-        end;
+        // Messages are processed during ValidateDirectory, so we may detect another change while
+        // updating the directory. Prevent the recursion.
+        // But retry the update afterwards (by reenabling the timer in ChangeDetected)
+        SuspendChangeTimer;
+        try
+          with DriveStatusPair.Value.ChangeTimer do
+          begin
+            Interval := 0;
+            Enabled := False;
+          end;
 
-        if Assigned(DriveStatusPair.Value.RootNode) then
-        begin
-          {Check also collapsed (invisible) subdirectories:}
-          ValidateDirectory(DriveStatusPair.Value.RootNode);
+          if Assigned(DriveStatusPair.Value.RootNode) then
+          begin
+            {Check also collapsed (invisible) subdirectories:}
+            ValidateDirectory(DriveStatusPair.Value.RootNode);
+          end;
+        finally
+          ResumeChangeTimer;
         end;
       end;
     end;