From 6a12373db08c964f74244a8923f2e4ab5d59b9d4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 19 Sep 2007 00:41:55 +0000 Subject: [PATCH] fix bug with deleting and recreating entries in wxFileConfig (patch 1796866) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@48776 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 4 ++++ src/common/fileconf.cpp | 30 +++++++++++------------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 20cb485b8d..e11356beaa 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -90,6 +90,10 @@ Major new features in 2.8 release 2.8.6 ----- +All: + +- Fixed another bug in wxFileConfig when deleting entries (Axel Gembe) + All (GUI): - Added an optimization to UI updates on idle, by only updating when the window diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index 3c59583b7e..f3d235bc83 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -1825,29 +1825,21 @@ bool wxFileConfigGroup::DeleteEntry(const wxChar *szName) // our last entry is being deleted - find the last one which stays wxASSERT( m_pLine != NULL ); // if we have an entry with !NULL pLine... - // go back until we find another entry or reach the group's line + // find the previous entry (if any) wxFileConfigEntry *pNewLast = NULL; - size_t n, nEntries = m_aEntries.Count(); - wxFileConfigLineList *pl; - for ( pl = pLine->Prev(); pl != m_pLine; pl = pl->Prev() ) { - // is it our subgroup? - for ( n = 0; (pNewLast == NULL) && (n < nEntries); n++ ) { - if ( m_aEntries[n]->GetLine() == m_pLine ) - pNewLast = m_aEntries[n]; - } - - if ( pNewLast != NULL ) // found? + const wxFileConfigLineList * const + pNewLastLine = m_pLastEntry->GetLine()->Prev(); + const size_t nEntries = m_aEntries.GetCount(); + for ( size_t n = 0; n < nEntries; n++ ) { + if ( m_aEntries[n]->GetLine() == pNewLastLine ) { + pNewLast = m_aEntries[n]; break; + } } - if ( pl == m_pLine ) { - wxASSERT( !pNewLast ); // how comes it has the same line as we? - - // we've reached the group line without finding any subgroups - m_pLastEntry = NULL; - } - else - m_pLastEntry = pNewLast; + // pNewLast can be NULL here -- it's ok and can happen if we have no + // entries left + m_pLastEntry = pNewLast; } m_pConfig->LineListRemove(pLine);