Browse Source

Bug 1829: Failure when changing directory using tree after resuming system from sleep (4rd)

https://winscp.net/tracker/1829

Source commit: 9c4d32003c30406b43b8d7b14f0ac2d485b73a1f
Martin Prikryl 5 years ago
parent
commit
e3e1a0380b
2 changed files with 10 additions and 2 deletions
  1. 1 1
      source/components/UnixDriveView.cpp
  2. 9 1
      source/packages/filemng/CustomDriveView.pas

+ 1 - 1
source/components/UnixDriveView.cpp

@@ -470,7 +470,7 @@ void __fastcall TCustomUnixDriveView::Change(TTreeNode * Node)
   {
     // During D&D Selected is set to NULL and then back to previous selection,
     // prevent actually changing directory in such case
-    if (Reading || ControlState.Contains(csRecreating) ||
+    if (Reading || ControlState.Contains(csRecreating) || FRecreatingHandle ||
         (Node == NULL) || (Node == FPrevSelected))
     {
       TCustomDriveView::Change(Node);

+ 9 - 1
source/packages/filemng/CustomDriveView.pas

@@ -43,6 +43,7 @@ type
     FContinue: Boolean;
     FImageList: TImageList;
     FScrollOnDragOver: TTreeViewScrollOnDragOver;
+    FRecreatingHandle: Boolean;
 
     FOnDDDragEnter: TDDOnDragEnter;
     FOnDDDragLeave: TDDOnDragLeave;
@@ -247,6 +248,7 @@ begin
   FContinue := True;
   FNaturalOrderNumericalSorting := True;
   FDarkMode := False;
+  FRecreatingHandle := False;
   OnCompare := DoCompare;
 
   FDragDropFilesEx := TCustomizableDragDropFilesEx.Create(Self);
@@ -961,7 +963,13 @@ begin
   // (as the handle is implicitly created somewhere in the middle of the reload and chaos ensures).
   if HadHandle then
   begin
-    HandleNeeded;
+    Assert(not FRecreatingHandle);
+    FRecreatingHandle := True;
+    try
+      HandleNeeded;
+    finally
+      FRecreatingHandle := False;
+    end;
   end;
 end;