+ // and then finally the group itself
+ wxFileConfigLineList *pLine = pGroup->m_pLine;
+ if ( pLine )
+ {
+ wxLogTrace( FILECONF_TRACE_MASK,
+ _T(" Removing line for group '%s' : '%s'"),
+ pGroup->Name().c_str(),
+ pLine->Text().c_str() );
+ wxLogTrace( FILECONF_TRACE_MASK,
+ _T(" Removing from group '%s' : '%s'"),
+ Name().c_str(),
+ ((m_pLine) ? m_pLine->Text().c_str() : wxEmptyString) );
+
+ // notice that we may do this test inside the previous "if"
+ // because the last entry's line is surely !NULL
+ if ( pGroup == m_pLastGroup )
+ {
+ wxLogTrace( FILECONF_TRACE_MASK,
+ _T(" Removing last group") );
+
+ // our last entry is being deleted, so find the last one which
+ // stays by going back until we find a subgroup or reach the
+ // group line
+ const size_t nSubgroups = m_aSubgroups.Count();
+
+ m_pLastGroup = NULL;
+ for ( wxFileConfigLineList *pl = pLine->Prev();
+ pl && pl != m_pLine && !m_pLastGroup;
+ pl = pl->Prev() )
+ {
+ // does this line belong to our subgroup?
+ for ( size_t n = 0; n < nSubgroups; n++ )
+ {
+ // do _not_ call GetGroupLine! we don't want to add it to
+ // the local file if it's not already there
+ if ( m_aSubgroups[n]->m_pLine == pl )
+ {
+ m_pLastGroup = m_aSubgroups[n];
+ break;
+ }
+ }
+ }
+ }