Bläddra i källkod

Bug 1880: Failure when trying to close WinSCP while reading a remote directory

https://winscp.net/tracker/1880

Source commit: 3ee46cddb889ca2d1b4875ff14bbe98ad16571e1
Martin Prikryl 5 år sedan
förälder
incheckning
5c82139b7b
3 ändrade filer med 24 tillägg och 2 borttagningar
  1. 22 1
      source/forms/CustomScpExplorer.cpp
  2. 1 0
      source/forms/CustomScpExplorer.h
  3. 1 1
      source/forms/NonVisual.cpp

+ 22 - 1
source/forms/CustomScpExplorer.cpp

@@ -4930,7 +4930,12 @@ void __fastcall TCustomScpExplorerForm::OpenFolderOrWorkspace(const UnicodeStrin
 void __fastcall TCustomScpExplorerForm::FormCloseQuery(TObject * /*Sender*/,
       bool &CanClose)
 {
-  if (Terminal != NULL)
+  // See the comment in CloseApp()
+  if (NonVisualDataModule->Busy)
+  {
+    CanClose = false;
+  }
+  else if (Terminal != NULL)
   {
     if (Terminal->Active && WinConfiguration->ConfirmClosingSession)
     {
@@ -10904,3 +10909,19 @@ void __fastcall TCustomScpExplorerForm::QueueFileListResize(TObject *)
   QueueFileListColumnAutoSize();
 }
 //---------------------------------------------------------------------------
+void __fastcall TCustomScpExplorerForm::CloseApp()
+{
+  // Called from TNonVisualDataModule::ExplorerActionsExecute, which sets busy flag.
+  // FormCloseQuery must check busy state, so that the application cannot be closed while busy by Alt+F4 and X button.
+  // So we clear the flag here.
+  DebugAssert(NonVisualDataModule->Busy);
+  NonVisualDataModule->EndBusy();
+  try
+  {
+    Close();
+  }
+  __finally
+  {
+    NonVisualDataModule->StartBusy();
+  }
+}

+ 1 - 0
source/forms/CustomScpExplorer.h

@@ -838,6 +838,7 @@ public:
   bool __fastcall IsComponentPossible(Byte Component);
   void __fastcall ReplaceTerminal(TManagedTerminal * value);
   virtual void __fastcall BrowseFile();
+  void __fastcall CloseApp();
 
   __property bool ComponentVisible[Byte Component] = { read = GetComponentVisible, write = SetComponentVisible };
   __property bool EnableFocusedOperation[TOperationSide Side] = { read = GetEnableFocusedOperation, index = 0 };

+ 1 - 1
source/forms/NonVisual.cpp

@@ -738,7 +738,7 @@ void __fastcall TNonVisualDataModule::ExplorerActionsExecute(
     EXE(ConsoleAction, ScpExplorer->OpenConsole())
     EXE(PuttyAction, TTerminalManager::Instance()->OpenInPutty())
     EXE(SynchronizeBrowsingAction, ScpExplorer->SynchronizeBrowsingChanged())
-    EXE(CloseApplicationAction, ScpExplorer->Close())
+    EXE(CloseApplicationAction, ScpExplorer->CloseApp())
     EXE(FileSystemInfoAction, ScpExplorer->FileSystemInfo())
     EXE(SessionGenerateUrlAction2, ScpExplorer->SessionGenerateUrl())
     EXE(ClearCachesAction, ScpExplorer->Terminal->ClearCaches())