Quellcode durchsuchen

Bug 1627: ssh:// URL is handled once for every opened instance of WinSCP too much (2nd try)

https://winscp.net/tracker/1627

Source commit: 209d6f0d14847b20bd620a105697969be820bcdf
Martin Prikryl vor 7 Jahren
Ursprung
Commit
0aa023f138
2 geänderte Dateien mit 12 neuen und 8 gelöschten Zeilen
  1. 10 1
      source/forms/CustomScpExplorer.cpp
  2. 2 7
      source/windows/WinMain.cpp

+ 10 - 1
source/forms/CustomScpExplorer.cpp

@@ -495,7 +495,16 @@ bool __fastcall TCustomScpExplorerForm::CommandLineFromAnotherInstance(
       UnicodeString SessionName = Params.Param[1];
       std::unique_ptr<TObjectList> DataList(new TObjectList());
       UnicodeString DownloadFile; // unused
-      GetLoginData(SessionName, &Params, DataList.get(), DownloadFile, true, this);
+      try
+      {
+        GetLoginData(SessionName, &Params, DataList.get(), DownloadFile, true, this);
+      }
+      catch (EAbort &)
+      {
+        // Happens when opening session in PuTTY and in other situations,
+        // in which we do not want to fail WM_COPYDATA, as that would cause master instance
+        // to process the command-line on its own (or to pass it to yet another instance)
+      }
       if (DataList->Count > 0)
       {
         TTerminalManager * Manager = TTerminalManager::Instance();

+ 2 - 7
source/windows/WinMain.cpp

@@ -26,7 +26,6 @@ void __fastcall GetLoginData(UnicodeString SessionName, TOptions * Options,
   TObjectList * DataList, UnicodeString & DownloadFile, bool NeedSession, TForm * LinkedForm)
 {
   bool DefaultsOnly = false;
-  bool Handled = false;
 
   UnicodeString FolderOrWorkspaceName = DecodeUrlChars(SessionName);
   if (StoredSessions->IsFolder(FolderOrWorkspaceName) ||
@@ -62,16 +61,12 @@ void __fastcall GetLoginData(UnicodeString SessionName, TOptions * Options,
         SessionData->ExpandEnvironmentVariables();
         OpenSessionInPutty(GUIConfiguration->PuttyPath, SessionData);
         DataList->Clear();
-        Handled = true;
+        Abort();
       }
     }
   }
 
-  if (Handled)
-  {
-     // noop
-  }
-  else if (DefaultsOnly && !NeedSession)
+  if (DefaultsOnly && !NeedSession)
   {
     // No URL specified on command-line and no explicit command-line parameter
     // that requires session was specified => noop