瀏覽代碼

Bug fix: Failure when opening workspace with local-local tab in Explorer interface

Source commit: 9aac31d676695c9d23f7997c1d87bfd64b600692
Martin Prikryl 3 年之前
父節點
當前提交
43e8bfcc35

+ 1 - 0
source/forms/CustomScpExplorer.h

@@ -785,6 +785,7 @@ public:
   virtual bool IsLocalBrowserMode();
   bool CanCloseSession(TManagedTerminal * Session);
   virtual UnicodeString __fastcall DefaultDownloadTargetDirectory() = 0;
+  virtual bool SupportedSession(TSessionData * SessionData) = 0;
 
   void __fastcall NewSession(const UnicodeString & SessionUrl = L"");
   virtual void NewTab(TOperationSide Side = osCurrent);

+ 5 - 0
source/forms/ScpCommander.cpp

@@ -2938,3 +2938,8 @@ UnicodeString TScpCommanderForm::GetNewTabHintDetails()
   }
   return Result;
 }
+//---------------------------------------------------------------------------
+bool TScpCommanderForm::SupportedSession(TSessionData *)
+{
+  return true;
+}

+ 1 - 0
source/forms/ScpCommander.h

@@ -672,6 +672,7 @@ public:
   virtual int GetNewTabActionImageIndex();
   virtual int GetNewTabTabImageIndex(TOperationSide Side);
   virtual UnicodeString __fastcall DefaultDownloadTargetDirectory();
+  virtual bool SupportedSession(TSessionData * SessionData);
 
   __property double LeftPanelWidth = { read = GetLeftPanelWidth, write = SetLeftPanelWidth };
 };

+ 4 - 0
source/forms/ScpExplorer.cpp

@@ -417,3 +417,7 @@ void __fastcall TScpExplorerForm::UpdateImages()
   UnixPathComboBox->SubMenuImages = ImageList;
 }
 //---------------------------------------------------------------------------
+bool TScpExplorerForm::SupportedSession(TSessionData * SessionData)
+{
+  return !SessionData->IsLocalBrowser;
+}

+ 1 - 0
source/forms/ScpExplorer.h

@@ -373,6 +373,7 @@ public:
   virtual void __fastcall ChangePath(TOperationSide Side);
   virtual void __fastcall GoToAddress();
   virtual UnicodeString __fastcall DefaultDownloadTargetDirectory();
+  virtual bool SupportedSession(TSessionData * SessionData);
 };
 //---------------------------------------------------------------------------
 #endif

+ 15 - 12
source/windows/TerminalManager.cpp

@@ -243,18 +243,21 @@ TManagedTerminal * __fastcall TTerminalManager::NewSessions(TList * DataList)
   for (int Index = 0; Index < DataList->Count; Index++)
   {
     TSessionData * Data = reinterpret_cast<TSessionData *>(DataList->Items[Index]);
-    TManagedTerminal * Session = DoNewSession(Data);
-    // When opening workspace/folder, keep the sessions open, even if they fail to connect.
-    // We cannot detect a folder here, so we "guess" it by a session set size.
-    // After all, no one will have a folder with a one session only (while a workspace with one session is likely).
-    // And when when opening a folder with a one session only, it's not that big problem, if we treat it the same way
-    // as when opening the session only.
-    // Also closing a workspace session will remove the session from the workspace.
-    // While closing a folder session won't remove the session from the folder.
-    Session->Permanent = Data->IsWorkspace || (DataList->Count > 1);
-    if (Index == 0)
-    {
-      Result = Session;
+    if (ScpExplorer->SupportedSession(Data))
+    {
+      TManagedTerminal * Session = DoNewSession(Data);
+      // When opening workspace/folder, keep the sessions open, even if they fail to connect.
+      // We cannot detect a folder here, so we "guess" it by a session set size.
+      // After all, no one will have a folder with a one session only (while a workspace with one session is likely).
+      // And when when opening a folder with a one session only, it's not that big problem, if we treat it the same way
+      // as when opening the session only.
+      // Also closing a workspace session will remove the session from the workspace.
+      // While closing a folder session won't remove the session from the folder.
+      Session->Permanent = Data->IsWorkspace || (DataList->Count > 1);
+      if (Result == NULL)
+      {
+        Result = Session;
+      }
     }
   }
   DoSessionListChanged();