Browse Source

Bug 1657: When canceling connection, mouse cursor sometimes stay "busy"

https://winscp.net/tracker/1657
(cherry picked from commit 0e146d6c7adb86d997324a80c2a274454634dfed)

# Conflicts:
#	source/windows/TerminalManager.cpp
#	source/windows/TerminalManager.h

Source commit: e6423865504fad7148c9bfa60a4e4b4bf19f12df
Martin Prikryl 7 years ago
parent
commit
f2dcd21243
3 changed files with 18 additions and 11 deletions
  1. 2 0
      source/core/Terminal.cpp
  2. 15 11
      source/windows/TerminalManager.cpp
  3. 1 0
      source/windows/TerminalManager.h

+ 2 - 0
source/core/Terminal.cpp

@@ -1435,6 +1435,8 @@ void __fastcall TTerminal::Open()
     }
     __finally
     {
+      // This does not make it through, if terminal thread is abandonded,
+      // see also TTerminalManager::DoConnectTerminal
       DoInformation(L"", true, 0);
     }
   }

+ 15 - 11
source/windows/TerminalManager.cpp

@@ -274,11 +274,10 @@ void __fastcall TTerminalManager::DoConnectTerminal(TTerminal * Terminal, bool R
         OwnsObjects = true;
         FActiveTerminal = Terminal;
 
-        // when abandoning cancelled terminal, the form remains open
-        if (FAuthenticateForm != NULL)
+        // When abandoning cancelled terminal, DoInformation(Phase = 0) does not make it to TerminalInformation handler.
+        if (DebugAlwaysTrue(FAuthenticating > 0))
         {
-          delete FAuthenticateForm;
-          FAuthenticateForm = NULL;
+          AuthenticatingDone();
         }
       }
       else
@@ -1117,6 +1116,17 @@ void __fastcall TTerminalManager::TerminalCustomCommand(
   Handled = CopyCommandToClipboard(Command);
 }
 //---------------------------------------------------------------------------
+void __fastcall TTerminalManager::AuthenticatingDone()
+{
+  FAuthenticating--;
+  if (FAuthenticating == 0)
+  {
+    BusyEnd(FBusyToken);
+    FBusyToken = NULL;
+  }
+  SAFE_DESTROY(FAuthenticateForm);
+}
+//---------------------------------------------------------------------------
 void __fastcall TTerminalManager::TerminalInformation(
   TTerminal * Terminal, const UnicodeString & Str, bool /*Status*/, int Phase)
 {
@@ -1132,13 +1142,7 @@ void __fastcall TTerminalManager::TerminalInformation(
   else if (Phase == 0)
   {
     DebugAssert(FAuthenticating > 0);
-    FAuthenticating--;
-    if (FAuthenticating == 0)
-    {
-      BusyEnd(FBusyToken);
-      FBusyToken = NULL;
-    }
-    SAFE_DESTROY(FAuthenticateForm);
+    AuthenticatingDone();
   }
   else
   {

+ 1 - 0
source/windows/TerminalManager.h

@@ -166,6 +166,7 @@ private:
   void __fastcall DoConfigurationChange();
   bool __fastcall ShouldDisplayQueueStatusOnAppTitle();
   void __fastcall SetupTerminal(TTerminal * Terminal);
+  void __fastcall AuthenticatingDone();
 };
 //---------------------------------------------------------------------------
 #endif