浏览代码

Bug 2060: Failure when changing remote folder using directory tree while previous directory is still loading

https://winscp.net/tracker/2060

Source commit: a2a66b37e2603f68677f4aa7074a42e63673c335
Martin Prikryl 3 年之前
父节点
当前提交
45a4ec27a8
共有 2 个文件被更改,包括 15 次插入1 次删除
  1. 14 1
      source/components/UnixDriveView.cpp
  2. 1 0
      source/components/UnixDriveView.h

+ 14 - 1
source/components/UnixDriveView.cpp

@@ -463,6 +463,13 @@ void __fastcall TCustomUnixDriveView::Delete(TTreeNode * Node)
   }
 }
 //---------------------------------------------------------------------------
+bool __fastcall TCustomUnixDriveView::CanChange(TTreeNode * Node)
+{
+  return
+    TCustomDriveView::CanChange(Node) &&
+    FCanChange;
+}
+//---------------------------------------------------------------------------
 void __fastcall TCustomUnixDriveView::Change(TTreeNode * Node)
 {
   #ifndef DESIGN_ONLY
@@ -502,7 +509,13 @@ void __fastcall TCustomUnixDriveView::Change(TTreeNode * Node)
         }
         try
         {
-          Terminal->ChangeDirectory(NodePathName(Node));
+          {
+            // Prevent curther changes while loading the folder.
+            // Particularly prevent user from trying to proceed with incremental search.
+            TValueRestorer<bool> CanChangeRestorer(FCanChange);
+            FCanChange = false;
+            Terminal->ChangeDirectory(NodePathName(Node));
+          }
           TCustomDriveView::Change(Node);
         }
         __finally

+ 1 - 0
source/components/UnixDriveView.h

@@ -33,6 +33,7 @@ protected:
   DYNAMIC void __fastcall Change(TTreeNode * Node);
   virtual void __fastcall CreateWnd();
   virtual void __fastcall DestroyWnd();
+  DYNAMIC bool __fastcall CanChange(TTreeNode * Node);
 
   void __fastcall LoadDirectory();
   TTreeNode * __fastcall LoadPath(UnicodeString Path);