Ver código fonte

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

Source commit: bcf59f4b26f402383810cabdde5d15a3adf45771
Martin Prikryl 1 ano atrás
pai
commit
b4f2a7024c
1 arquivos alterados com 19 adições e 5 exclusões
  1. 19 5
      source/packages/filemng/CustomDirView.pas

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

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