[ wxwindows-Bugs-1521693 ] WxFileConfig DeleteGroup - recreates deleted groups

SourceForge.net noreply at sourceforge.net
Thu Jul 13 02:23:01 PDT 2006


Bugs item #1521693, was opened at 2006-07-13 12:23
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1521693&group_id=9863

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Common
Group: Must fix
Status: Open
Resolution: None
Priority: 5
Submitted By: Nachum Kanovsky (nachumk)
Assigned to: Nobody/Anonymous (nobody)
Summary: WxFileConfig DeleteGroup - recreates deleted groups

Initial Comment:
(Sample program attached)

Important note is that these bugs recreate the group
but they only appear in memory during iterations over
the group, or calls to getnumberofgroups /
getfirstgroup / getnextgroup. Since entries under the
group path have all been deleted, and only the path has
been recreated nothing is under the group so it is
removed when written back to file.

I have been tracing a bug wherein a call to deletegroup
doesn't remove the group. I have found this bug to
appear in 2 functions:

Since wxConfigPathChanger is used when entering
DeleteGroup, the function can't recreate the group when
exiting which is what happens during the
wxConfigPathChanger destructor. I think the destructor
must verify the existence of the path, or DeleteGroup
should check if the current path is a subpath of the
path being deleted before using a wxConfigPathChanger
to restore the old path.

Here is a fix in the wxConfigPathChanger destructor

wxConfigPathChanger::~wxConfigPathChanger()
{
 // only restore path if it was changed
 if ( m_bChanged ) {
  //next line added to attempt to fix bug
  if ( m_pContainer->HasGroup(m_strOldPath) ){
   m_pContainer->SetPath(m_strOldPath);
  } //this line added to attempt to fix bug
 }
}

This previously would store the path even if that path
was now deleted, and the call to SetPath would recreate
deleted path.

Another issues seems that HasEntry (called from Exists)
creates the path to the key that is is checking for.
Perhaps that is intended and it should be known that
HasEntry creates the group, but it causes problems when
iterating through groups.

The problem is somewhat solved if you close and reopen
the fileconfig object b/c the recreated keys are all
empty, therefore they are not written out in the file.
The problem is of issue when calling GetFirstGroup, or
GetNextGroup b/c the keys have been recreated in
memory. See attached file for a demo of this issue.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1521693&group_id=9863




More information about the wx-dev mailing list