From 09007b50a06fe96ad78d4f0480d8172ed8ff7487 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sun, 6 Apr 2003 12:19:23 +0000 Subject: [PATCH] Fixed assert (and crash in debug) in wxFileConfigGroup::DeleteSubgroupByName Backported from CVS head git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20005 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/common/fileconf.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index cee2f56d59..d587258b1d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -178,6 +178,7 @@ All: - fixed wxLANGUAGE_CHINESE_TAIWAN to use zh_TW catalogs - added missing wx/quantize.h to install - improved wxScrolledWindow/sizer interaction +- fixed assert (and crash in debug) in wxFileConfigGroup::DeleteSubgroupByName Unix (GUI): diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index c93a8f5d01..171eb89d78 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -1512,13 +1512,17 @@ wxFileConfigGroup *wxFileConfigGroup::AddSubgroup(const wxString& strName) bool wxFileConfigGroup::DeleteSubgroupByName(const wxChar *szName) { - return DeleteSubgroup(FindSubgroup(szName)); + wxFileConfigGroup * const pGroup = FindSubgroup(szName); + + return pGroup ? DeleteSubgroup(pGroup) : FALSE; } // Delete the subgroup and remove all references to it from // other data structures. bool wxFileConfigGroup::DeleteSubgroup(wxFileConfigGroup *pGroup) { + wxCHECK_MSG( pGroup, FALSE, _T("deleting non existing group?") ); + wxLogTrace( _T("wxFileConfig"), _T("Deleting group '%s' from '%s'"), pGroup->Name().c_str(), @@ -1533,10 +1537,7 @@ bool wxFileConfigGroup::DeleteSubgroup(wxFileConfigGroup *pGroup) _T(" text: '%s'"), ((m_pLine) ? m_pLine->Text().c_str() : wxEmptyString) ); - wxCHECK_MSG( pGroup != 0, FALSE, _T("deleting non existing group?") ); - // delete all entries - size_t nCount = pGroup->m_aEntries.Count(); wxLogTrace(_T("wxFileConfig"),