fix wxConfig::DeleteGroup() for arguments with trailing slash (replaces patch 1624589)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44126 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -97,6 +97,7 @@ All:
|
|||||||
- wxGrid::GetBestSize() returns same size the grid would have after AutoSize()
|
- wxGrid::GetBestSize() returns same size the grid would have after AutoSize()
|
||||||
- Added wxTreeCtrl::CollapseAll[Children]() and IsEmpty() (Francesco Montorsi)
|
- Added wxTreeCtrl::CollapseAll[Children]() and IsEmpty() (Francesco Montorsi)
|
||||||
- Several RTL-related positioning fixes (Diaa Sami)
|
- Several RTL-related positioning fixes (Diaa Sami)
|
||||||
|
- Fix wxConfig::DeleteGroup() for arguments with trailing slash (David Hart)
|
||||||
|
|
||||||
wxMSW:
|
wxMSW:
|
||||||
|
|
||||||
|
@@ -225,7 +225,7 @@ public:
|
|||||||
// delete the group (with all subgroups)
|
// delete the group (with all subgroups)
|
||||||
virtual bool DeleteGroup(const wxString& key) = 0;
|
virtual bool DeleteGroup(const wxString& key) = 0;
|
||||||
// delete the whole underlying object (disk file, registry key, ...)
|
// delete the whole underlying object (disk file, registry key, ...)
|
||||||
// primarly for use by desinstallation routine.
|
// primarily for use by uninstallation routine.
|
||||||
virtual bool DeleteAll() = 0;
|
virtual bool DeleteAll() = 0;
|
||||||
|
|
||||||
// options
|
// options
|
||||||
@@ -254,6 +254,13 @@ protected:
|
|||||||
static bool IsImmutable(const wxString& key)
|
static bool IsImmutable(const wxString& key)
|
||||||
{ return !key.IsEmpty() && key[0] == wxCONFIG_IMMUTABLE_PREFIX; }
|
{ return !key.IsEmpty() && key[0] == wxCONFIG_IMMUTABLE_PREFIX; }
|
||||||
|
|
||||||
|
// return the path without trailing separator, if any: this should be called
|
||||||
|
// to sanitize paths referring to the group names before passing them to
|
||||||
|
// wxConfigPathChanger as "/foo/bar/" should be the same as "/foo/bar" and it
|
||||||
|
// isn't interpreted in the same way by it (and this can't be changed there
|
||||||
|
// as it's not the same for the entries names)
|
||||||
|
static wxString RemoveTrailingSeparator(const wxString& key);
|
||||||
|
|
||||||
// do read/write the values of different types
|
// do read/write the values of different types
|
||||||
virtual bool DoReadString(const wxString& key, wxString *pStr) const = 0;
|
virtual bool DoReadString(const wxString& key, wxString *pStr) const = 0;
|
||||||
virtual bool DoReadLong(const wxString& key, long *pl) const = 0;
|
virtual bool DoReadLong(const wxString& key, long *pl) const = 0;
|
||||||
|
@@ -1172,7 +1172,7 @@ bool wxFileConfig::DeleteEntry(const wxString& key, bool bGroupIfEmptyAlso)
|
|||||||
|
|
||||||
bool wxFileConfig::DeleteGroup(const wxString& key)
|
bool wxFileConfig::DeleteGroup(const wxString& key)
|
||||||
{
|
{
|
||||||
wxConfigPathChanger path(this, key);
|
wxConfigPathChanger path(this, RemoveTrailingSeparator(key));
|
||||||
|
|
||||||
if ( !m_pCurrentGroup->DeleteSubgroupByName(path.Name()) )
|
if ( !m_pCurrentGroup->DeleteSubgroupByName(path.Name()) )
|
||||||
return false;
|
return false;
|
||||||
|
@@ -697,7 +697,7 @@ bool wxRegConfig::DeleteEntry(const wxString& value, bool bGroupIfEmptyAlso)
|
|||||||
|
|
||||||
bool wxRegConfig::DeleteGroup(const wxString& key)
|
bool wxRegConfig::DeleteGroup(const wxString& key)
|
||||||
{
|
{
|
||||||
wxConfigPathChanger path(this, key);
|
wxConfigPathChanger path(this, RemoveTrailingSeparator(key));
|
||||||
|
|
||||||
if ( !m_keyLocal.Exists() )
|
if ( !m_keyLocal.Exists() )
|
||||||
{
|
{
|
||||||
|
@@ -309,7 +309,8 @@ void FileConfigTestCase::DeleteGroup()
|
|||||||
_T("[root/group2]\n"),
|
_T("[root/group2]\n"),
|
||||||
fc );
|
fc );
|
||||||
|
|
||||||
CPPUNIT_ASSERT( fc.DeleteGroup(_T("root/group2")) );
|
// notice trailing slash: it should be ignored
|
||||||
|
CPPUNIT_ASSERT( fc.DeleteGroup(_T("root/group2/")) );
|
||||||
wxVERIFY_FILECONFIG( _T("[root]\n")
|
wxVERIFY_FILECONFIG( _T("[root]\n")
|
||||||
_T("entry=value\n"),
|
_T("entry=value\n"),
|
||||||
fc );
|
fc );
|
||||||
|
Reference in New Issue
Block a user