Sfoglia il codice sorgente

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

https://winscp.net/tracker/1880
(cherry picked from commit 5c82139b7b29ba5db3af1fdb7d11be9a044ea8a5)

# Conflicts:
#	source/forms/CustomScpExplorer.cpp

Source commit: 8f9d35ea6d65363c26c741228839801505b12097
Martin Prikryl 5 anni fa
parent
commit
78dbbe04ed

+ 22 - 1
source/forms/CustomScpExplorer.cpp

@@ -4909,7 +4909,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)
     {
@@ -10737,3 +10742,19 @@ void __fastcall TCustomScpExplorerForm::BrowseFile()
   }
 }
 //---------------------------------------------------------------------------
+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

@@ -821,6 +821,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

@@ -735,7 +735,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())