wxRegConfig now works again

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@696 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1998-09-07 08:55:28 +00:00
parent fd2daa68f4
commit 040f0110fc
2 changed files with 61 additions and 56 deletions

View File

@@ -71,62 +71,60 @@ bool TryGetValue(const wxRegKey& key, const wxString& str, long *plVal)
// ctor/dtor // ctor/dtor
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if 0 // create the config object which stores its data under HKCU\vendor\app and, if
wxRegConfig::wxRegConfig(const wxString& strRoot) // style & wxCONFIG_USE_GLOBAL_FILE, under HKLM\vendor\app
: m_keyLocalRoot(wxRegKey::HKCU, SOFTWARE_KEY + strRoot),
m_keyLocal(m_keyLocalRoot, ""),
m_keyGlobalRoot(wxRegKey::HKLM, SOFTWARE_KEY + strRoot),
m_keyGlobal(m_keyGlobalRoot, "")
{
// Create() will Open() if key already exists
m_keyLocalRoot.Create();
// as it's the same key, Open() shouldn't fail (i.e. no need for Create())
m_keyLocal.Open();
wxLogNull nolog;
m_keyGlobalRoot.Open();
}
#endif
// TODO: vendor name is ignored, because we can't yet do the test for optional vendor
// name in the constructor body. We need a wxRegKey::Set that takes the same
// args as the constructor. Then we'll set m_keyLocalRoot etc. in the constructor body.
wxRegConfig::wxRegConfig(const wxString& appName, const wxString& vendorName, wxRegConfig::wxRegConfig(const wxString& appName, const wxString& vendorName,
const wxString& strLocal, const wxString& strGlobal, long style) const wxString& strLocal, const wxString& strGlobal,
: wxConfigBase(appName, vendorName, strLocal, strGlobal, style), long style)
: wxConfigBase(appName, vendorName, strLocal, strGlobal, style)
m_keyLocalRoot(wxRegKey::HKCU, SOFTWARE_KEY + appName),
m_keyLocal(m_keyLocalRoot, ""),
m_keyGlobalRoot(wxRegKey::HKLM, SOFTWARE_KEY + appName),
m_keyGlobal(m_keyGlobalRoot, "")
{ {
// TODO: really, we should check and supply an app name if one isn't supplied. wxString strRoot;
// Unfortunately I don't know how to initialise the member wxRegKey
// variables from within the constructor body. -- JACS
// Vadim - we just need an implementation of wxRegKey::Set,
// and then we can uncomment this and remove the constructor lines above.
/*
wxString strRoot(appName);
if (appName.IsEmpty() && wxTheApp)
{
strRoot = wxTheApp->GetAppName();
}
wxASSERT( !strRoot.IsEmpty() );
if (!vendorName.IsEmpty()) bool bDoUseGlobal = (style & wxCONFIG_USE_GLOBAL_FILE) != 0;
// the convention is to put the programs keys under <vendor>\<appname>
// (but it can be overriden by specifying the pathes explicitly in strLocal
// and/or strGlobal)
if ( strLocal.IsEmpty() || (strGlobal.IsEmpty() && bDoUseGlobal) )
{
if ( vendorName.IsEmpty() )
{ {
strRoot += "\\"; if ( wxTheApp )
strRoot += vendorName; strRoot = wxTheApp->GetVendorName();
}
else
{
strRoot = vendorName;
} }
m_keyLocalRoot.Set(wxRegKey::HKCU, SOFTWARE_KEY + strRoot), // no '\\' needed if no vendor name
m_keyLocal.Set(m_keyLocalRoot, ""), if ( !strRoot.IsEmpty() )
{
strRoot += '\\';
}
m_keyGlobalRoot.Set(wxRegKey::HKLM, SOFTWARE_KEY + strRoot), if ( appName.IsEmpty() )
m_keyGlobal.Set(m_keyGlobalRoot, "") {
*/ wxCHECK_RET( wxTheApp, "No application name in wxRegConfig ctor!" );
strRoot << wxTheApp->GetAppName();
}
else
{
strRoot << appName;
}
}
//else: we don't need to do all the complicated stuff above
wxString str = strLocal.IsEmpty() ? strRoot : strLocal;
m_keyLocalRoot.SetName(wxRegKey::HKCU, SOFTWARE_KEY + str);
m_keyLocal.SetName(m_keyLocalRoot, "");
if ( bDoUseGlobal )
{
str = strGlobal.IsEmpty() ? strRoot : strGlobal;
m_keyGlobalRoot.SetName(wxRegKey::HKLM, SOFTWARE_KEY + str);
m_keyGlobal.SetName(m_keyGlobalRoot, "");
}
// Create() will Open() if key already exists // Create() will Open() if key already exists
m_keyLocalRoot.Create(); m_keyLocalRoot.Create();
@@ -134,9 +132,13 @@ wxRegConfig::wxRegConfig(const wxString& appName, const wxString& vendorName,
// as it's the same key, Open() shouldn't fail (i.e. no need for Create()) // as it's the same key, Open() shouldn't fail (i.e. no need for Create())
m_keyLocal.Open(); m_keyLocal.Open();
wxLogNull nolog; // OTOH, this key may perfectly not exist, so suppress error messages the call
m_keyGlobalRoot.Open(); // to Open() might generate
if ( bDoUseGlobal )
{
wxLogNull nolog;
m_keyGlobalRoot.Open();
}
} }
wxRegConfig::~wxRegConfig() wxRegConfig::~wxRegConfig()

View File

@@ -887,11 +887,14 @@ bool GetFileTypeIcon(wxIcon *pIcon, const wxString& strFileType)
// NB: icon index may be negative as well as positive and the full path // NB: icon index may be negative as well as positive and the full path
// may contain the environment variables inside '%' // may contain the environment variables inside '%'
wxString strFullPath = strIcon.Before(','), wxString strFullPath = strIcon.Before(','),
strIndex = strIcon.After(','); strIndex = strIcon.Right(',');
// unless I misunderstand the format (may be index may be ommited, I // index may be omitted, in which case Before(',') is empty and
// don't know) // Right(',') is the whole string
wxASSERT( !(strFullPath.IsEmpty() || strIndex.IsEmpty()) ); if ( strFullPath.IsEmpty() ) {
strFullPath = strIndex;
strIndex = "0";
}
wxString strExpPath = wxExpandEnvVars(strFullPath); wxString strExpPath = wxExpandEnvVars(strFullPath);
int nIndex = atoi(strIndex); int nIndex = atoi(strIndex);