Explorar o código

Bug fix: When there are both site folder and site with the same name and the site was selected when closing the Login dialog, when reopening, the folder was selected instead

Similarly when importing size with the same name as existing site folder, the folder was selected after the imported instead of the imported site

(cherry picked from commit 5dabeda2f7aae0c1d7e327ced290e6240c5bd98f)

Source commit: 32545bad1f33940eab892820f76737284e7f458e
Martin Prikryl %!s(int64=4) %!d(string=hai) anos
pai
achega
b7cb64b2e6
Modificáronse 1 ficheiros con 9 adicións e 6 borrados
  1. 9 6
      source/forms/Login.cpp

+ 9 - 6
source/forms/Login.cpp

@@ -1413,7 +1413,12 @@ void __fastcall TLoginDialog::SaveState()
 
     WinConfiguration->OpenedStoredSessionFolders = OpenedStoredSessionFolders->CommaText;
 
-    WinConfiguration->LastStoredSession = SessionNodePath(SessionTree->Selected);
+    UnicodeString LastStoredSession = SessionNodePath(SessionTree->Selected);
+    if (IsFolderNode(SessionTree->Selected))
+    {
+      LastStoredSession = UnixIncludeTrailingBackslash(LastStoredSession);
+    }
+    WinConfiguration->LastStoredSession = LastStoredSession;
 
     TLoginDialogConfiguration DialogConfiguration = CustomWinConfiguration->LoginDialog;
     DialogConfiguration.WindowSize = StoreFormSize(this);
@@ -1485,7 +1490,8 @@ void __fastcall TLoginDialog::LoadState()
   if (!FForceNewSite &&
       !WinConfiguration->LastStoredSession.IsEmpty() && DebugAlwaysTrue(Visible))
   {
-    UnicodeString Path = WinConfiguration->LastStoredSession;
+    UnicodeString Path = UnixExcludeTrailingBackslash(WinConfiguration->LastStoredSession);
+    bool Folder = (Path != WinConfiguration->LastStoredSession);
 
     UnicodeString ParentPath = UnixExtractFilePath(Path);
     TTreeNode * Node;
@@ -1502,10 +1508,7 @@ void __fastcall TLoginDialog::LoadState()
     if (Node != NULL)
     {
       UnicodeString Name = UnixExtractFileName(Path);
-      // actually we cannot distinguish folder and session here
-      // (note that we allow folder and session with the same name),
-      // this is pending for future improvements
-      while ((Node != NULL) && !AnsiSameText(Node->Text, Name))
+      while ((Node != NULL) && (!SameText(Node->Text, Name) || (IsFolderNode(Node) != Folder)))
       {
         Node = Node->getNextSibling();
       }