git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40095
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
\func{bool}{DeleteGroup}{\param{const wxString\& }{ key}}
\func{bool}{DeleteGroup}{\param{const wxString\& }{ key}}
-Delete the group (with all subgroups)
+Delete the group (with all subgroups). If the current path is under the group
+being deleted it is changed to its deepest still existing component. E.g. if
+the current path is \texttt{/A/B/C/D} and the group \texttt{C} is deleted the
+path becomes \texttt{/A/B}.
\membersection{wxConfigBase::Exists}\label{wxconfigbaseexists}
\membersection{wxConfigBase::Exists}\label{wxconfigbaseexists}
+void wxConfigPathChanger::UpdateIfDeleted()
+{
+ // we don't have to do anything at all if we didn't change the path
+ if ( !m_bChanged )
+ return;
+
+ // find the deepest still existing parent path of the original path
+ while ( !m_pContainer->HasGroup(m_strOldPath) )
+ {
+ m_strOldPath = m_strOldPath.BeforeLast(wxCONFIG_PATH_SEPARATOR);
+ if ( m_strOldPath.empty() )
+ m_strOldPath = wxCONFIG_PATH_SEPARATOR;
+ }
+}
+
wxConfigPathChanger::~wxConfigPathChanger()
{
// only restore path if it was changed
wxConfigPathChanger::~wxConfigPathChanger()
{
// only restore path if it was changed
if ( !m_pCurrentGroup->DeleteSubgroupByName(path.Name()) )
return false;
if ( !m_pCurrentGroup->DeleteSubgroupByName(path.Name()) )
return false;
+ path.UpdateIfDeleted();
+
{
wxConfigPathChanger path(this, key);
{
wxConfigPathChanger path(this, key);
- return m_keyLocal.Exists() ? LocalKey().DeleteKey(path.Name()) : true;
+ if ( !m_keyLocal.Exists() )
+ {
+ // nothing to do
+ return true;
+ }
+
+ if ( !LocalKey().DeleteKey(path.Name()) )
+ return false;
+
+ path.UpdateIfDeleted();
+
+ return true;
}
bool wxRegConfig::DeleteAll()
}
bool wxRegConfig::DeleteAll()
-#endif
- // wxUSE_CONFIG