Procházet zdrojové kódy

Bug fix: Settings with an empty default value were not listed in Add Raw Site Settings dialog

Source commit: 0d01127ceaebf85fe1ea4d675a83dcc57bc8c97b
Martin Prikryl před 6 roky
rodič
revize
b93bd1246f

+ 18 - 0
source/core/Common.cpp

@@ -4036,3 +4036,21 @@ TStrings * TlsCipherList()
 
   return Result.release();
 }
+//---------------------------------------------------------------------------
+void SetStringValueEvenIfEmpty(TStrings * Strings, const UnicodeString & Name, const UnicodeString & Value)
+{
+  if (Value.IsEmpty())
+  {
+    int Index = Strings->IndexOfName(Name);
+    if (Index < 0)
+    {
+      Index = Strings->Add(L"");
+    }
+    UnicodeString Line = Name + Strings->NameValueSeparator;
+    Strings->Strings[Index] = Line;
+  }
+  else
+  {
+    Strings->Values[Name] = Value;
+  }
+}

+ 1 - 0
source/core/Common.h

@@ -181,6 +181,7 @@ UnicodeString __fastcall GetFileMimeType(const UnicodeString & FileName);
 bool __fastcall IsRealFile(const UnicodeString & FileName);
 UnicodeString GetOSInfo();
 UnicodeString GetEnvironmentInfo();
+void SetStringValueEvenIfEmpty(TStrings * Strings, const UnicodeString & Name, const UnicodeString & Value);
 //---------------------------------------------------------------------------
 struct TSearchRecSmart : public TSearchRec
 {

+ 1 - 1
source/core/HierarchicalStorage.cpp

@@ -1781,7 +1781,7 @@ void __fastcall TOptionsIniFile::WriteString(const UnicodeString Section, const
       DebugAlwaysTrue(AllowSection(Section)))
   {
     UnicodeString Name = FormatKey(Section, Ident);
-    FOptions->Values[Name] = Value;
+    SetStringValueEvenIfEmpty(FOptions, Name, Value);
   }
 }
 //---------------------------------------------------------------------------

+ 1 - 14
source/forms/Custom.cpp

@@ -1263,20 +1263,7 @@ bool __fastcall TCustomCommandOptionsDialog::Execute(TShortCut * ShortCut)
 
           // The default value setter deletes the "name" when the value is empty.
           // It would cause us to fall back to the default value, but we want to remember the empty value.
-          if (Value.IsEmpty())
-          {
-            int Index = FCustomCommandOptions->IndexOfName(OptionKey);
-            if (Index < 0)
-            {
-              Index = FCustomCommandOptions->Add(L"");
-            }
-            UnicodeString Line = OptionKey + FCustomCommandOptions->NameValueSeparator;
-            FCustomCommandOptions->Strings[Index] = Line;
-          }
-          else
-          {
-            FCustomCommandOptions->Values[OptionKey] = Value;
-          }
+          SetStringValueEvenIfEmpty(FCustomCommandOptions, OptionKey, Value);
         }
 
         ControlIndex++;