Răsfoiți Sursa

Bug 1684: Failure when canceling session reconnect

https://winscp.net/tracker/1684

Source commit: db4a195ba366aeeaf53dcfad11535960dcc61d91
Martin Prikryl 7 ani în urmă
părinte
comite
726522c522

+ 20 - 15
source/forms/CustomScpExplorer.cpp

@@ -525,22 +525,27 @@ void __fastcall TCustomScpExplorerForm::SetTerminal(TTerminal * value)
   if (FTerminal != value)
   {
     TerminalChanging();
-    FTerminal = value;
-    bool PrevAllowTransferPresetAutoSelect = FAllowTransferPresetAutoSelect;
-    FAllowTransferPresetAutoSelect = false;
-    try
-    {
-      TerminalChanged();
-    }
-    __finally
-    {
-      FAllowTransferPresetAutoSelect = PrevAllowTransferPresetAutoSelect;
-    }
+    ReplaceTerminal(value);
+  }
+}
+//---------------------------------------------------------------------------
+void __fastcall TCustomScpExplorerForm::ReplaceTerminal(TTerminal * value)
+{
+  FTerminal = value;
+  bool PrevAllowTransferPresetAutoSelect = FAllowTransferPresetAutoSelect;
+  FAllowTransferPresetAutoSelect = false;
+  try
+  {
+    TerminalChanged();
+  }
+  __finally
+  {
+    FAllowTransferPresetAutoSelect = PrevAllowTransferPresetAutoSelect;
+  }
 
-    if (Terminal != NULL)
-    {
-      TransferPresetAutoSelect();
-    }
+  if (Terminal != NULL)
+  {
+    TransferPresetAutoSelect();
   }
 }
 //---------------------------------------------------------------------------

+ 1 - 0
source/forms/CustomScpExplorer.h

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

+ 2 - 0
source/windows/TerminalManager.cpp

@@ -279,6 +279,8 @@ void __fastcall TTerminalManager::DoConnectTerminal(TTerminal * Terminal, bool R
           Items[ActiveTerminalIndex] = Terminal;
           OwnsObjects = true;
           FActiveTerminal = Terminal;
+          // Not to call TerminalChanging() => UpdateTerminal() on a terminal that might be already released
+          FScpExplorer->ReplaceTerminal(Terminal);
         }
 
         // When abandoning cancelled terminal, DoInformation(Phase = 0) does not make it to TerminalInformation handler.