浏览代码

Bug fix: Ad hoc site opened from a workspace showed its internal number a name instead of a friendly generated name

Caused by Bug 1183.

Source commit: 5bc71929b6c16e00c1c783150ca435ef1e7d8184
Martin Prikryl 6 年之前
父节点
当前提交
e67d16ab1d
共有 1 个文件被更改,包括 12 次插入31 次删除
  1. 12 31
      source/core/SessionData.cpp

+ 12 - 31
source/core/SessionData.cpp

@@ -2883,19 +2883,7 @@ UnicodeString __fastcall TSessionData::GetNameWithoutHiddenPrefix()
 //---------------------------------------------------------------------
 bool __fastcall TSessionData::HasSessionName()
 {
-  UnicodeString ALocalName = ExtractLocalName(Name);
-  bool AIsWorkspaceSessionWithoutName = IsWorkspace && (ALocalName.Length() == 4); // See SaveWorkspaceData()
-  if (AIsWorkspaceSessionWithoutName)
-  {
-    int Index = 1;
-    while (AIsWorkspaceSessionWithoutName && (Index <= ALocalName.Length()))
-    {
-      AIsWorkspaceSessionWithoutName = IsHex(ALocalName[Index]);
-      Index++;
-    }
-  }
-
-  return (!GetNameWithoutHiddenPrefix().IsEmpty() && (Name != DefaultName) && !AIsWorkspaceSessionWithoutName);
+  return (!GetNameWithoutHiddenPrefix().IsEmpty() && (Name != DefaultName));
 }
 //---------------------------------------------------------------------
 UnicodeString __fastcall TSessionData::GetSessionName()
@@ -4852,6 +4840,12 @@ void __fastcall TStoredSessionList::GetFolderOrWorkspace(const UnicodeString & N
       {
         Data2->Name = RawData->NameOverride;
       }
+      else if (RawData->Link.IsEmpty())
+      {
+        // Newly opened ad-hoc session has no name, so restore the workspace that way too.
+        // Otherwise we would persist the generated internal workspace name as a real name.
+        Data2->Name = UnicodeString();
+      }
 
       List->Add(Data2);
     }
@@ -4861,26 +4855,13 @@ void __fastcall TStoredSessionList::GetFolderOrWorkspace(const UnicodeString & N
 TStrings * __fastcall TStoredSessionList::GetFolderOrWorkspaceList(
   const UnicodeString & Name)
 {
-  std::unique_ptr<TStringList> Result(new TStringList());
+  std::unique_ptr<TObjectList> DataList(new TObjectList());
+  GetFolderOrWorkspace(Name, DataList.get());
 
-  for (int Index = 0; (Index < Count); Index++)
+  std::unique_ptr<TStringList> Result(new TStringList());
+  for (int Index = 0; (Index < DataList->Count); Index++)
   {
-    TSessionData * Data =
-      CheckIsInFolderOrWorkspaceAndResolve(Sessions[Index], Name);
-
-    if (Data != NULL)
-    {
-      UnicodeString Name;
-      if (!Data->NameOverride.IsEmpty())
-      {
-        Name = Data->NameOverride;
-      }
-      else
-      {
-        Name = Data->SessionName;
-      }
-      Result->Add(Name);
-    }
+    Result->Add(dynamic_cast<TSessionData *>(DataList->Items[Index])->SessionName);
   }
 
   return Result.release();