if ( appName.IsEmpty() )
{
- wxCHECK_RET( wxTheApp, "No application name in wxRegConfig ctor!" );
+ wxCHECK_RET( wxTheApp, wxT("No application name in wxRegConfig ctor!") );
strRoot << wxTheApp->GetAppName();
}
else
}
// recombine path parts in one variable
- wxString strRegPath;
+ wxString strOldPath = m_strPath, strRegPath;
m_strPath.Empty();
for ( size_t n = 0; n < aParts.Count(); n++ ) {
strRegPath << '\\' << aParts[n];
m_strPath << wxCONFIG_PATH_SEPARATOR << aParts[n];
}
+ if ( m_strPath == strOldPath )
+ return;
+
+ // as we create the registry key when SetPath(key) is done, we can be left
+ // with plenty of empty keys if this was only done to try to read some value
+ // which, in fact, doesn't exist - to prevent this from happening we
+ // automatically delete the old key if it was empty
+ if ( m_keyLocal.IsEmpty() )
+ {
+ m_keyLocal.DeleteSelf();
+ }
+
// change current key(s)
m_keyLocal.SetName(m_keyLocalRoot, strRegPath);
m_keyGlobal.SetName(m_keyGlobalRoot, strRegPath);
if ( IsImmutable(path.Name()) ) {
if ( TryGetValue(m_keyGlobal, path.Name(), *pStr) ) {
if ( m_keyLocal.HasValue(path.Name()) ) {
- wxLogWarning("User value for immutable key '%s' ignored.",
+ wxLogWarning(wxT("User value for immutable key '%s' ignored."),
path.Name().c_str());
}
*pStr = wxConfigBase::ExpandEnvVars(*pStr);
if ( IsImmutable(path.Name()) ) {
if ( TryGetValue(m_keyGlobal, path.Name(), *pStr) ) {
if ( m_keyLocal.HasValue(path.Name()) ) {
- wxLogWarning("User value for immutable key '%s' ignored.",
+ wxLogWarning(wxT("User value for immutable key '%s' ignored."),
path.Name().c_str());
}
if ( IsImmutable(path.Name()) ) {
if ( TryGetValue(m_keyGlobal, path.Name(), plResult) ) {
if ( m_keyLocal.HasValue(path.Name()) ) {
- wxLogWarning("User value for immutable key '%s' ignored.",
+ wxLogWarning(wxT("User value for immutable key '%s' ignored."),
path.Name().c_str());
}
wxConfigPathChanger path(this, key);
if ( IsImmutable(path.Name()) ) {
- wxLogError("Can't change immutable entry '%s'.", path.Name().c_str());
+ wxLogError(wxT("Can't change immutable entry '%s'."), path.Name().c_str());
return FALSE;
}
wxConfigPathChanger path(this, key);
if ( IsImmutable(path.Name()) ) {
- wxLogError("Can't change immutable entry '%s'.", path.Name().c_str());
+ wxLogError(wxT("Can't change immutable entry '%s'."), path.Name().c_str());
return FALSE;
}
// TODO there is no way to rename a registry key - we must do a deep copy
// ourselves
- wxFAIL_MSG("Registry key renaming not implemented");
+ wxFAIL_MSG(wxT("Registry key renaming not implemented"));
return FALSE;
}
if ( !m_keyLocal.DeleteValue(path.Name()) )
return FALSE;
- if ( !m_keyLocal.HasSubkeys() ) {
+ if ( m_keyLocal.IsEmpty() ) {
wxString strKey = GetPath().AfterLast(wxCONFIG_PATH_SEPARATOR);
SetPath(".."); // changes m_keyLocal
return m_keyLocal.DeleteKey(strKey);