فهرست منبع

Bug 1509: Failure while reloading directory tree after a system colors had changed while the tree was not showing

https://winscp.net/tracker/1509

Source commit: ad9a5892d9106ddf1a4bf412961759d8d417d2a8
Martin Prikryl 8 سال پیش
والد
کامیت
b46d24bc1b
2فایلهای تغییر یافته به همراه31 افزوده شده و 0 حذف شده
  1. 15 0
      source/packages/filemng/CustomDirView.pas
  2. 16 0
      source/packages/filemng/CustomDriveView.pas

+ 15 - 0
source/packages/filemng/CustomDirView.pas

@@ -188,6 +188,7 @@ type
     procedure WMAppCommand(var Message: TMessage); message WM_APPCOMMAND;
     procedure CMColorChanged(var Message: TMessage); message CM_COLORCHANGED;
     procedure LVMSetExtendedListViewStyle(var Message: TMessage); message LVM_SETEXTENDEDLISTVIEWSTYLE;
+    procedure CMRecreateWnd(var Message: TMessage); message CM_RECREATEWND;
 
     procedure DumbCustomDrawItem(Sender: TCustomListView; Item: TListItem;
       State: TCustomDrawState; var DefaultDraw: Boolean);
@@ -1192,6 +1193,20 @@ begin
   inherited;
 end;
 
+procedure TCustomDirView.CMRecreateWnd(var Message: TMessage);
+var
+  HadHandle: Boolean;
+begin
+  HadHandle := HandleAllocated;
+  inherited;
+  // See comment in TCustomDriveView.CMRecreateWnd
+  if HadHandle then
+  begin
+    HandleNeeded;
+  end;
+end;
+
+
 function TCustomDirView.CustomDrawItem(Item: TListItem; State: TCustomDrawState;
   Stage: TCustomDrawStage): Boolean;
 var

+ 16 - 0
source/packages/filemng/CustomDriveView.pas

@@ -81,6 +81,7 @@ type
 
     procedure CNNotify(var Msg: TWMNotify); message CN_NOTIFY;
     procedure CMColorChanged(var Msg: TMessage); message CM_COLORCHANGED;
+    procedure CMRecreateWnd(var Msg: TMessage); message CM_RECREATEWND;
     procedure WMLButtonDown(var Msg: TWMLButtonDown); message WM_LBUTTONDOWN;
     procedure WMLButtonUp(var Msg: TWMLButtonDown); message WM_LBUTTONUP;
     procedure WMRButtonDown(var Msg: TWMRButtonDown); message WM_RBUTTONDOWN;
@@ -900,6 +901,21 @@ begin
   end;
 end; {WMContextMenu}
 
+procedure TCustomDriveView.CMRecreateWnd(var Msg: TMessage);
+var
+  HadHandle: Boolean;
+begin
+  HadHandle := HandleAllocated;
+  inherited;
+  // If the control is not showing (e.g. because the machine is locked), the handle is not recreated.
+  // If contents is reloaded (LoadPath) without handle allocated, it crashes
+  // (as the handle is implicitly created somewhere in the middle of the reload and chaos ensures).
+  if HadHandle then
+  begin
+    HandleNeeded;
+  end;
+end;
+
 procedure TCustomDriveView.Delete(Node: TTreeNode);
 begin
   if Node = FDragNode then