1
0
Эх сурвалжийг харах

Bug fix: Failure when system theme change is broadcasted in short order

Source commit: bcf59f4b26f402383810cabdde5d15a3adf45771
Martin Prikryl 1 жил өмнө
parent
commit
b4f2a7024c

+ 19 - 5
source/packages/filemng/CustomDirView.pas

@@ -180,6 +180,7 @@ type
     FOnChangeFocus: TDirViewChangeFocusEvent;
     FFallbackThumbnail: array[Boolean] of TBitmap;
     FFallbackThumbnailSize: TSize;
+    FRecreatingWnd: Integer;
 
     procedure CNNotify(var Message: TWMNotify); message CN_NOTIFY;
     procedure WMNotify(var Msg: TWMNotify); message WM_NOTIFY;
@@ -1417,12 +1418,25 @@ procedure TCustomDirView.CMRecreateWnd(var Message: TMessage);
 var
   HadHandle: Boolean;
 begin
-  HadHandle := HandleAllocated;
-  inherited;
-  // See comment in TCustomDriveView.CMRecreateWnd
-  if HadHandle then
+  Inc(FRecreatingWnd);
+  if FRecreatingWnd = 1 then
   begin
-    HandleNeeded;
+    HadHandle := HandleAllocated;
+    try
+      // Prevent nesting
+      while FRecreatingWnd > 0 do
+      begin
+        inherited;
+        Dec(FRecreatingWnd);
+      end;
+    finally
+      FRecreatingWnd := 0;
+    end;
+    // See comment in TCustomDriveView.CMRecreateWnd
+    if HadHandle then
+    begin
+      HandleNeeded;
+    end;
   end;
 end;