Browse Source

Bug fix: Failure when closing application after giving up trying to reconnect a broken connection

The bug was invisible to the user, but caused high failure-rate in 5.8.1-5.8.3 (ReportsWithError around 15%)

The bug was caused by the commit 3855c25ba "Closing application when Login dialog opened after handling URL with "save" extension is canceled."

This commit also rolls back the commit 1bc6dce5b "Memory leak when connection fails" as that only worked around a  common root cause.

Source commit: c9a1823c6b04cef21e17ba50cad84ad2c7b53ba6
Martin Prikryl 9 years ago
parent
commit
81961efcaa
2 changed files with 22 additions and 20 deletions
  1. 9 1
      source/forms/CustomScpExplorer.cpp
  2. 13 19
      source/windows/TerminalManager.cpp

+ 9 - 1
source/forms/CustomScpExplorer.cpp

@@ -5739,7 +5739,15 @@ void __fastcall TCustomScpExplorerForm::LastTerminalClosed(TObject * /*Sender*/)
   UpdateControls();
   SessionColor = TColor(0);
   UpdateRemotePathComboBox(false);
-  NeedSession(true);
+  try
+  {
+    NeedSession(true);
+  }
+  catch (EAbort &)
+  {
+    // swallow
+    // The TTerminalManager does not expect the OnLastTerminalClose to throw without trying to connect
+  }
 }
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::NeedSession(bool ReloadSessions)

+ 13 - 19
source/windows/TerminalManager.cpp

@@ -468,34 +468,28 @@ void __fastcall TTerminalManager::FreeTerminal(TTerminal * Terminal)
     FQueues->Delete(Index);
     FTerminationMessages->Delete(Index);
 
-    try
+    if (ActiveTerminal && (Terminal == ActiveTerminal))
     {
-      if (ActiveTerminal && (Terminal == ActiveTerminal))
+      if ((Count > 0) && !FDestroying)
       {
-        if ((Count > 0) && !FDestroying)
-        {
-          ActiveTerminal = Terminals[Index < Count ? Index : Index - 1];
-        }
-        else
-        {
-          ActiveTerminal = NULL;
-        }
+        ActiveTerminal = Terminals[Index < Count ? Index : Index - 1];
       }
       else
       {
-        SaveTerminal(Terminal);
+        ActiveTerminal = NULL;
       }
     }
-    // ActiveTerminal = NULL throws EAbort when Login dialog is closed
-    __finally
+    else
     {
-      // only now all references to/from queue (particularly events to explorer)
-      // are cleared
-      delete Queue;
-      delete Terminal;
-
-      DoTerminalListChanged();
+      SaveTerminal(Terminal);
     }
+
+    // only now all references to/from queue (particularly events to explorer)
+    // are cleared
+    delete Queue;
+    delete Terminal;
+
+    DoTerminalListChanged();
   }
 }
 //---------------------------------------------------------------------------