Browse Source

Bug 2059: Removing all custom commands resets the default ones when INI file is used

https://winscp.net/tracker/2059

Source commit: 9fbd9bbe83b2114bec5bb693641c8a2c2a22bdd5
Martin Prikryl 3 years ago
parent
commit
d24d0c28b8
1 changed files with 11 additions and 1 deletions
  1. 11 1
      source/windows/WinConfiguration.cpp

+ 11 - 1
source/windows/WinConfiguration.cpp

@@ -1177,6 +1177,15 @@ void __fastcall TWinConfiguration::SaveData(THierarchicalStorage * Storage, bool
   if ((All && !FCustomCommandsDefaults) || FCustomCommandList->Modified)
   {
     FCustomCommandList->Save(Storage);
+
+    if (FCustomCommandList->Count == 0)
+    {
+      Storage->WriteBool(L"CustomCommandsNone", true);
+    }
+    else
+    {
+      Storage->DeleteValue(L"CustomCommandsNone");
+    }
   }
 
   if ((All || FCustomCommandOptionsModified) &&
@@ -1509,7 +1518,8 @@ void __fastcall TWinConfiguration::LoadData(THierarchicalStorage * Storage)
     Storage->CloseSubKey();
   }
 
-  if (Storage->KeyExists(L"CustomCommands"))
+  if (Storage->KeyExists(L"CustomCommands") ||
+      Storage->ReadBool(L"CustomCommandsNone", false))
   {
     FCustomCommandList->Load(Storage);
     FCustomCommandsDefaults = false;