浏览代码

Removing OpenRootKey assertion invalidated by bf9594fd and probably never needed + Though adding another assertion to generally suspicious OpenRootKey code.

Source commit: 9aa8a3bcd07310773a0ef1b8900186ae8e26e557
Martin Prikryl 3 年之前
父节点
当前提交
1b198d1cc3
共有 2 个文件被更改,包括 5 次插入11 次删除
  1. 4 9
      source/core/HierarchicalStorage.cpp
  2. 1 2
      source/core/HierarchicalStorage.h

+ 4 - 9
source/core/HierarchicalStorage.cpp

@@ -189,6 +189,10 @@ void __fastcall THierarchicalStorage::ConfigureForPutty()
 //---------------------------------------------------------------------------
 bool __fastcall THierarchicalStorage::OpenRootKey(bool CanCreate)
 {
+  // This do not seem to be doing what it advertises.
+  // It probably "works" only when used as a first "Open". So let's verify that by this assertion.
+  DebugAssert(CurrentSubKey.IsEmpty());
+
   return OpenSubKey(UnicodeString(), CanCreate);
 }
 //---------------------------------------------------------------------------
@@ -1152,15 +1156,6 @@ bool __fastcall TCustomIniFileStorage::DoOpenSubKey(const UnicodeString & SubKey
   return Result;
 }
 //---------------------------------------------------------------------------
-bool __fastcall TCustomIniFileStorage::OpenRootKey(bool CanCreate)
-{
-  // Not supported with master storage.
-  // Actually currently, we use OpenRootKey with TRegistryStorage only.
-  DebugAssert(FMasterStorage.get() == NULL);
-
-  return THierarchicalStorage::OpenRootKey(CanCreate);
-}
-//---------------------------------------------------------------------------
 bool __fastcall TCustomIniFileStorage::OpenSubKey(const UnicodeString & Key, bool CanCreate)
 {
   bool Result;

+ 1 - 2
source/core/HierarchicalStorage.h

@@ -18,7 +18,7 @@ public:
   __fastcall THierarchicalStorage(const UnicodeString & AStorage);
   virtual __fastcall ~THierarchicalStorage();
   void __fastcall ConfigureForPutty();
-  virtual bool __fastcall OpenRootKey(bool CanCreate);
+  bool __fastcall OpenRootKey(bool CanCreate);
   virtual bool __fastcall OpenSubKey(const UnicodeString & SubKey, bool CanCreate);
   virtual void __fastcall CloseSubKey();
   void __fastcall CloseAll();
@@ -200,7 +200,6 @@ public:
   __fastcall TCustomIniFileStorage(const UnicodeString & Storage, TCustomIniFile * IniFile);
   virtual __fastcall ~TCustomIniFileStorage();
 
-  virtual bool __fastcall OpenRootKey(bool CanCreate);
   virtual bool __fastcall OpenSubKey(const UnicodeString & SubKey, bool CanCreate);
 
 private: