Browse Source

Bug fix: When opening ssh:// URL in PuTTY or handling URL with a save extension, a main window was opened

Source commit: 949c145cd9112e3ba2483330289578bf367c7a6a
Martin Prikryl 9 năm trước cách đây
mục cha
commit
85d613d806
1 tập tin đã thay đổi với 18 bổ sung23 xóa
  1. 18 23
      source/windows/WinMain.cpp

+ 18 - 23
source/windows/WinMain.cpp

@@ -27,7 +27,6 @@ void __fastcall GetLoginData(UnicodeString SessionName, TOptions * Options,
   TObjectList * DataList, UnicodeString & DownloadFile, bool NeedSession)
 {
   bool DefaultsOnly = false;
-  bool Close = false;
 
   if (StoredSessions->IsFolder(SessionName) ||
       StoredSessions->IsWorkspace(SessionName))
@@ -48,11 +47,11 @@ void __fastcall GetLoginData(UnicodeString SessionName, TOptions * Options,
       {
         Configuration->Usage->Inc(L"CommandLineSessionSave");
         TSessionData * SavedSession = DoSaveSession(SessionData, NULL, true, NULL);
-        Close = (SavedSession == NULL);
-        if (!Close)
+        if (SavedSession == NULL)
         {
-          WinConfiguration->LastStoredSession = SavedSession->Name;
+          Abort();
         }
+        WinConfiguration->LastStoredSession = SavedSession->Name;
         DataList->Clear();
       }
       else if (!SessionData->PuttyProtocol.IsEmpty())
@@ -61,33 +60,29 @@ void __fastcall GetLoginData(UnicodeString SessionName, TOptions * Options,
         // though it's hardly of any use here.
         SessionData->ExpandEnvironmentVariables();
         OpenSessionInPutty(GUIConfiguration->PuttyPath, SessionData);
-        DataList->Clear();
-        Close = true;
+        Abort();
       }
     }
   }
 
-  if (!Close)
+  if (DefaultsOnly && !NeedSession)
+  {
+    // No URL specified on command-line and no explicit command-line parameter
+    // that results session was specified => noop
+    DataList->Clear();
+  }
+  else if ((DataList->Count == 0) ||
+      !dynamic_cast<TSessionData *>(DataList->Items[0])->CanLogin ||
+      DefaultsOnly)
   {
-    if (DefaultsOnly && !NeedSession)
+    // Note that GetFolderOrWorkspace never returns sites that !CanLogin,
+    // so we should not get here with more then one site.
+    // Though we should be good, if we ever do.
+    DebugAssert(DataList->Count <= 1);
+    if (!DoLoginDialog(StoredSessions, DataList, loStartup))
     {
-      // No URL specified on command-line and no explicit command-line parameter
-      // that results session was specified => noop
       DataList->Clear();
     }
-    else if ((DataList->Count == 0) ||
-        !dynamic_cast<TSessionData *>(DataList->Items[0])->CanLogin ||
-        DefaultsOnly)
-    {
-      // Note that GetFolderOrWorkspace never returns sites that !CanLogin,
-      // so we should not get here with more then one site.
-      // Though we should be good, if we ever do.
-      DebugAssert(DataList->Count <= 1);
-      if (!DoLoginDialog(StoredSessions, DataList, loStartup))
-      {
-        DataList->Clear();
-      }
-    }
   }
 }
 //---------------------------------------------------------------------------