Browse Source

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

https://winscp.net/tracker/1657

Source commit: 8df06d080e47d9748bd4acd0c9c426eeaca88f96
Martin Prikryl 7 years ago
parent
commit
0e146d6c7a
3 changed files with 24 additions and 12 deletions
  1. 2 0
      source/core/Terminal.cpp
  2. 21 12
      source/windows/TerminalManager.cpp
  3. 1 0
      source/windows/TerminalManager.h

+ 2 - 0
source/core/Terminal.cpp

@@ -1438,6 +1438,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);
     }
   }

+ 21 - 12
source/windows/TerminalManager.cpp

@@ -281,8 +281,12 @@ void __fastcall TTerminalManager::DoConnectTerminal(TTerminal * Terminal, bool R
           FActiveTerminal = Terminal;
         }
 
-        // when abandoning cancelled terminal, the form remains open
-        CloseAutheticateForm();
+        // When abandoning cancelled terminal, DoInformation(Phase = 0) does not make it to TerminalInformation handler.
+        if (DebugAlwaysTrue(FAuthenticating > 0))
+        {
+          FKeepAuthenticateForm = false;
+          AuthenticatingDone();
+        }
       }
       else
       {
@@ -1111,6 +1115,20 @@ void __fastcall TTerminalManager::TerminalCustomCommand(
   Handled = CopyCommandToClipboard(Command);
 }
 //---------------------------------------------------------------------------
+void __fastcall TTerminalManager::AuthenticatingDone()
+{
+  FAuthenticating--;
+  if (FAuthenticating == 0)
+  {
+    BusyEnd(FBusyToken);
+    FBusyToken = NULL;
+  }
+  if (!FKeepAuthenticateForm)
+  {
+    CloseAutheticateForm();
+  }
+}
+//---------------------------------------------------------------------------
 void __fastcall TTerminalManager::TerminalInformation(
   TTerminal * Terminal, const UnicodeString & Str, bool /*Status*/, int Phase)
 {
@@ -1126,16 +1144,7 @@ void __fastcall TTerminalManager::TerminalInformation(
   else if (Phase == 0)
   {
     DebugAssert(FAuthenticating > 0);
-    FAuthenticating--;
-    if (FAuthenticating == 0)
-    {
-      BusyEnd(FBusyToken);
-      FBusyToken = NULL;
-    }
-    if (!FKeepAuthenticateForm)
-    {
-      CloseAutheticateForm();
-    }
+    AuthenticatingDone();
   }
   else
   {

+ 1 - 0
source/windows/TerminalManager.h

@@ -169,6 +169,7 @@ private:
   bool __fastcall ShouldDisplayQueueStatusOnAppTitle();
   void __fastcall SetupTerminal(TTerminal * Terminal);
   void __fastcall CloseAutheticateForm();
+  void __fastcall AuthenticatingDone();
   TRemoteFile * __fastcall CheckRights(
     TTerminal * Terminal, const UnicodeString & EntryType, const UnicodeString & FileName, bool & WrongRights);
 };