char buf[1024];
do
{
- inStream.Read(buf, WXSIZEOF(buf));
+ inStream.Read(buf, WXSIZEOF(buf)-1); // leave room for the NULL
const wxStreamError err = inStream.GetLastError();
if ( !m_pCurrentGroup->DeleteEntry(path.Name()) )
return false;
+ SetDirty();
+
if ( bGroupIfEmptyAlso && m_pCurrentGroup->IsEmpty() ) {
if ( m_pCurrentGroup != m_pRootGroup ) {
wxFileConfigGroup *pGroup = m_pCurrentGroup;
SetPath(wxT("..")); // changes m_pCurrentGroup!
- if ( m_pCurrentGroup->DeleteSubgroupByName(pGroup->Name()) )
- SetDirty();
+ m_pCurrentGroup->DeleteSubgroupByName(pGroup->Name());
}
//else: never delete the root group
}
}
else // this entry didn't exist in the local file
{
- // add a new line to the file: note the hack for the root group
- // which is special in that it doesn't have its own group line
- // (something like "[/]") and so the line we get for it may be not
- // its line at all if it doesn't have any entries
- //
- // this is definitely not the right place to fix it but changing
- // the root group to have NULL m_pLine will probably break too
- // much stuff elsewhere so I don't dare to do it...
+ // add a new line to the file: note that line returned by
+ // GetLastEntryLine() may be NULL if we're in the root group and it
+ // doesn't have any entries yet, but this is ok as passing NULL
+ // line to LineListInsert() means to prepend new line to the list
wxFileConfigLineList *line = Group()->GetLastEntryLine();
- if ( !Group()->Parent() && line == Group()->GetGroupLine() )
- {
- // prepend the first root group entry to the head of the list
- line = NULL;
- }
m_pLine = Group()->Config()->LineListInsert(strLine, line);
Group()->SetLastEntry(this);