+ wxCHECK_MSG( pGroup, false, wxT("deleting non existing group?") );
+
+ wxLogTrace( FILECONF_TRACE_MASK,
+ wxT("Deleting group '%s' from '%s'"),
+ pGroup->Name().c_str(),
+ Name().c_str() );
+
+ wxLogTrace( FILECONF_TRACE_MASK,
+ wxT(" (m_pLine) = prev: %p, this %p, next %p"),
+ m_pLine ? static_cast<void*>(m_pLine->Prev()) : 0,
+ static_cast<void*>(m_pLine),
+ m_pLine ? static_cast<void*>(m_pLine->Next()) : 0 );
+ wxLogTrace( FILECONF_TRACE_MASK,
+ wxT(" text: '%s'"),
+ m_pLine ? (const wxChar*)m_pLine->Text().c_str()
+ : wxEmptyString );
+
+ // delete all entries...
+ size_t nCount = pGroup->m_aEntries.GetCount();
+
+ wxLogTrace(FILECONF_TRACE_MASK,
+ wxT("Removing %lu entries"), (unsigned long)nCount );
+
+ for ( size_t nEntry = 0; nEntry < nCount; nEntry++ )
+ {
+ wxFileConfigLineList *pLine = pGroup->m_aEntries[nEntry]->GetLine();
+
+ if ( pLine )
+ {
+ wxLogTrace( FILECONF_TRACE_MASK,
+ wxT(" '%s'"),
+ pLine->Text().c_str() );
+ m_pConfig->LineListRemove(pLine);
+ }
+ }
+
+ // ...and subgroups of this subgroup
+ nCount = pGroup->m_aSubgroups.GetCount();
+
+ wxLogTrace( FILECONF_TRACE_MASK,
+ wxT("Removing %lu subgroups"), (unsigned long)nCount );
+
+ for ( size_t nGroup = 0; nGroup < nCount; nGroup++ )
+ {
+ pGroup->DeleteSubgroup(pGroup->m_aSubgroups[0]);
+ }
+
+ // and then finally the group itself
+ wxFileConfigLineList *pLine = pGroup->m_pLine;
+ if ( pLine )
+ {
+ wxLogTrace( FILECONF_TRACE_MASK,
+ wxT(" Removing line for group '%s' : '%s'"),
+ pGroup->Name().c_str(),
+ pLine->Text().c_str() );
+ wxLogTrace( FILECONF_TRACE_MASK,
+ wxT(" Removing from group '%s' : '%s'"),
+ Name().c_str(),
+ ((m_pLine) ? (const wxChar*)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,
+ wxT(" 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.GetCount();
+
+ m_pLastGroup = NULL;
+ for ( wxFileConfigLineList *pl = pLine->Prev();
+ pl && !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;
+ }
+ }
+
+ if ( pl == m_pLine )
+ break;
+ }
+ }
+
+ m_pConfig->LineListRemove(pLine);
+ }
+ else
+ {
+ wxLogTrace( FILECONF_TRACE_MASK,
+ wxT(" No line entry for Group '%s'?"),
+ pGroup->Name().c_str() );
+ }