From c8adf5ef39b0cfdfe23423cc1ef6409fb22a297d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 4 Oct 2004 08:53:23 +0000 Subject: [PATCH] don't try to delete our config file in DeleteAll() if we don't have any; don't assert when trying to delete an entry which doesn't exist (for consistency with DeleteGroup() and wxRegConfig) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29641 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/fileconf.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index f79f88014f..f86bd415dd 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -1107,13 +1107,19 @@ bool wxFileConfig::DeleteAll() { CleanUp(); - if ( wxFile::Exists(m_strLocalFile) && wxRemove(m_strLocalFile) == -1 ) + if ( !m_strLocalFile.empty() ) { - wxLogSysError(_("can't delete user configuration file '%s'"), m_strLocalFile.c_str()); - return false; + if ( wxFile::Exists(m_strLocalFile) && wxRemove(m_strLocalFile) == -1 ) + { + wxLogSysError(_("can't delete user configuration file '%s'"), + m_strLocalFile.c_str()); + return false; + } + + m_strLocalFile = + m_strGlobalFile = wxT(""); } - m_strLocalFile = m_strGlobalFile = wxT(""); Init(); return true; @@ -1709,7 +1715,11 @@ bool wxFileConfigGroup::DeleteSubgroup(wxFileConfigGroup *pGroup) bool wxFileConfigGroup::DeleteEntry(const wxChar *szName) { wxFileConfigEntry *pEntry = FindEntry(szName); - wxCHECK( pEntry != NULL, false ); // deleting non existing item? + if ( !pEntry ) + { + // entry doesn't exist, nothing to do + return false; + } wxFileConfigLineList *pLine = pEntry->GetLine(); if ( pLine != NULL ) { -- 2.45.2