浏览代码

Bug 1684: Failure when canceling session reconnect

https://winscp.net/tracker/1684
(cherry picked from commit 726522c5229e754efca98668dceb6f94cf684005)

# Conflicts:
#	source/forms/CustomScpExplorer.cpp
#	source/windows/TerminalManager.cpp

Source commit: 3bdbb819adbd7b41758182d2b018a99c29450d36
Martin Prikryl 7 年之前
父节点
当前提交
2eeff60bcd
共有 3 个文件被更改,包括 23 次插入15 次删除
  1. 20 15
      source/forms/CustomScpExplorer.cpp
  2. 1 0
      source/forms/CustomScpExplorer.h
  3. 2 0
      source/windows/TerminalManager.cpp

+ 20 - 15
source/forms/CustomScpExplorer.cpp

@@ -530,22 +530,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

@@ -710,6 +710,7 @@ public:
   bool __fastcall CanChangePassword();
   void __fastcall ChangePassword();
   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

@@ -273,6 +273,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.
         if (DebugAlwaysTrue(FAuthenticating > 0))