소스 검색

Bug 1433: Failure due to a disconnected session being left behind after opening a secondary shell session fails

https://winscp.net/tracker/1433

Caused by 3f7c904638 (Closing main session with the secondary one to avoid mismatch in terminal's event handler)

Source commit: 14416328be1b7aec7e51c4fa5c59f46b7c5e732b
Martin Prikryl 9 년 전
부모
커밋
d480042fe9
4개의 변경된 파일13개의 추가작업 그리고 5개의 파일을 삭제
  1. 7 0
      source/core/Terminal.cpp
  2. 1 0
      source/core/Terminal.h
  3. 3 3
      source/forms/CustomScpExplorer.cpp
  4. 2 2
      source/windows/UserInterface.cpp

+ 7 - 0
source/core/Terminal.cpp

@@ -6056,6 +6056,13 @@ bool __fastcall TTerminal::CanRecurseToDirectory(const TRemoteFile * File)
   return !File->IsSymLink || FSessionData->FollowDirectorySymlinks;
 }
 //---------------------------------------------------------------------------
+bool __fastcall TTerminal::IsThisOrChild(TTerminal * Terminal)
+{
+  return
+    (this == Terminal) ||
+    ((FCommandSession != NULL) && (FCommandSession == Terminal));
+}
+//---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 __fastcall TSecondaryTerminal::TSecondaryTerminal(TTerminal * MainTerminal,
   TSessionData * ASessionData, TConfiguration * Configuration, const UnicodeString & Name) :

+ 1 - 0
source/core/Terminal.h

@@ -492,6 +492,7 @@ public:
   void __fastcall FatalAbort();
   void __fastcall ReflectSettings();
   void __fastcall CollectUsage();
+  bool __fastcall IsThisOrChild(TTerminal * Terminal);
 
   const TSessionInfo & __fastcall GetSessionInfo();
   const TFileSystemInfo & __fastcall GetFileSystemInfo(bool Retrieve = false);

+ 3 - 3
source/forms/CustomScpExplorer.cpp

@@ -7315,10 +7315,10 @@ void __fastcall TCustomScpExplorerForm::RemoteFileControlDDQueryContinueDrag(
       // If downloading fails we need to cancel drag&drop, otherwise
       // Explorer shows error
       // But by the way exception probably never reach this point as
-      // it's catched on way
+      // it's catched on way.
+      // Fatal exceptions get here (like when opening a secondary shell extension for file duplication fails).
       Result = DRAGDROP_S_CANCEL;
-      DebugAssert(Terminal != NULL);
-      Terminal->ShowExtendedException(&E);
+      ShowExtendedException(Terminal, &E);
     }
   }
 }

+ 2 - 2
source/windows/UserInterface.cpp

@@ -173,10 +173,10 @@ void __fastcall ShowExtendedExceptionEx(TTerminal * Terminal,
       WinConfiguration->ConfirmExitOnCompletion;
 
     if (E->InheritsFrom(__classid(EFatal)) && (Terminal != NULL) &&
-        (Manager != NULL) && (Manager->ActiveTerminal == Terminal))
+        (Manager != NULL) && (Manager->ActiveTerminal != NULL) && Manager->ActiveTerminal->IsThisOrChild(Terminal))
     {
       int SessionReopenTimeout = 0;
-      TManagedTerminal * ManagedTerminal = dynamic_cast<TManagedTerminal *>(Terminal);
+      TManagedTerminal * ManagedTerminal = dynamic_cast<TManagedTerminal *>(Manager->ActiveTerminal);
       if ((ManagedTerminal != NULL) &&
           ((Configuration->SessionReopenTimeout == 0) ||
            ((double)ManagedTerminal->ReopenStart == 0) ||