X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e90c1d2a19361551eb07778280f22be3e759cf64..28be2e8a170979d476a5ea4f585505b8a2f5af27:/src/msw/regconf.cpp diff --git a/src/msw/regconf.cpp b/src/msw/regconf.cpp index 5d18e7f81a..404fb0d2d2 100644 --- a/src/msw/regconf.cpp +++ b/src/msw/regconf.cpp @@ -27,6 +27,9 @@ #include "wx/event.h" #include "wx/app.h" #include "wx/log.h" + +#if wxUSE_CONFIG + #include "wx/config.h" #ifndef __WIN16__ @@ -98,7 +101,7 @@ wxRegConfig::wxRegConfig(const wxString& appName, const wxString& vendorName, if ( appName.IsEmpty() ) { - wxCHECK_RET( wxTheApp, T("No application name in wxRegConfig ctor!") ); + wxCHECK_RET( wxTheApp, wxT("No application name in wxRegConfig ctor!") ); strRoot << wxTheApp->GetAppName(); } else @@ -160,13 +163,25 @@ void wxRegConfig::SetPath(const wxString& strPath) } // 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); @@ -337,7 +352,7 @@ bool wxRegConfig::Read(const wxString& key, wxString *pStr) const if ( IsImmutable(path.Name()) ) { if ( TryGetValue(m_keyGlobal, path.Name(), *pStr) ) { if ( m_keyLocal.HasValue(path.Name()) ) { - wxLogWarning(T("User value for immutable key '%s' ignored."), + wxLogWarning(wxT("User value for immutable key '%s' ignored."), path.Name().c_str()); } *pStr = wxConfigBase::ExpandEnvVars(*pStr); @@ -373,7 +388,7 @@ bool wxRegConfig::Read(const wxString& key, wxString *pStr, if ( IsImmutable(path.Name()) ) { if ( TryGetValue(m_keyGlobal, path.Name(), *pStr) ) { if ( m_keyLocal.HasValue(path.Name()) ) { - wxLogWarning(T("User value for immutable key '%s' ignored."), + wxLogWarning(wxT("User value for immutable key '%s' ignored."), path.Name().c_str()); } @@ -416,7 +431,7 @@ bool wxRegConfig::Read(const wxString& key, long *plResult) const if ( IsImmutable(path.Name()) ) { if ( TryGetValue(m_keyGlobal, path.Name(), plResult) ) { if ( m_keyLocal.HasValue(path.Name()) ) { - wxLogWarning(T("User value for immutable key '%s' ignored."), + wxLogWarning(wxT("User value for immutable key '%s' ignored."), path.Name().c_str()); } @@ -441,7 +456,7 @@ bool wxRegConfig::Write(const wxString& key, const wxString& szValue) wxConfigPathChanger path(this, key); if ( IsImmutable(path.Name()) ) { - wxLogError(T("Can't change immutable entry '%s'."), path.Name().c_str()); + wxLogError(wxT("Can't change immutable entry '%s'."), path.Name().c_str()); return FALSE; } @@ -453,7 +468,7 @@ bool wxRegConfig::Write(const wxString& key, long lValue) wxConfigPathChanger path(this, key); if ( IsImmutable(path.Name()) ) { - wxLogError(T("Can't change immutable entry '%s'."), path.Name().c_str()); + wxLogError(wxT("Can't change immutable entry '%s'."), path.Name().c_str()); return FALSE; } @@ -516,7 +531,7 @@ bool wxRegConfig::RenameGroup(const wxString& oldName, const wxString& newName) // TODO there is no way to rename a registry key - we must do a deep copy // ourselves - wxFAIL_MSG(T("Registry key renaming not implemented")); + wxFAIL_MSG(wxT("Registry key renaming not implemented")); return FALSE; } @@ -565,3 +580,5 @@ bool wxRegConfig::DeleteAll() #endif // __WIN16__ +#endif + // wxUSE_CONFIG