minor changes and bug corrections (interface unchanged)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@423 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -88,13 +88,16 @@ public:
|
|||||||
// static functions
|
// static functions
|
||||||
// sets the config object, returns the previous pointer
|
// sets the config object, returns the previous pointer
|
||||||
static wxConfigBase *Set(wxConfigBase *pConfig);
|
static wxConfigBase *Set(wxConfigBase *pConfig);
|
||||||
// get the config object, creates it on demand
|
// get the config object, creates it on demand unless DontCreateOnDemand
|
||||||
|
// was called
|
||||||
static wxConfigBase *Get() { if ( !ms_pConfig ) Create(); return ms_pConfig; }
|
static wxConfigBase *Get() { if ( !ms_pConfig ) Create(); return ms_pConfig; }
|
||||||
// create a new config object: this function will create the "best"
|
// create a new config object: this function will create the "best"
|
||||||
// implementation of wxConfig available for the current platform, see
|
// implementation of wxConfig available for the current platform, see
|
||||||
// comments near definition wxCONFIG_WIN32_NATIVE for details. It returns
|
// comments near definition wxCONFIG_WIN32_NATIVE for details. It returns
|
||||||
// the created object and also sets it as ms_pConfig.
|
// the created object and also sets it as ms_pConfig.
|
||||||
static wxConfigBase *Create();
|
static wxConfigBase *Create();
|
||||||
|
// should Get() try to create a new log object if the current one is NULL?
|
||||||
|
static void DontCreateOnDemand() { ms_bAutoCreate = FALSE; }
|
||||||
|
|
||||||
// ctor & virtual dtor
|
// ctor & virtual dtor
|
||||||
// environment variable expansion is on by default
|
// environment variable expansion is on by default
|
||||||
@@ -211,6 +214,7 @@ private:
|
|||||||
|
|
||||||
// static variables
|
// static variables
|
||||||
static wxConfigBase *ms_pConfig;
|
static wxConfigBase *ms_pConfig;
|
||||||
|
static bool ms_bAutoCreate;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -229,3 +233,4 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif //_wxCONFIG_H
|
#endif //_wxCONFIG_H
|
||||||
|
|
||||||
|
@@ -74,7 +74,8 @@ public:
|
|||||||
bool HasPendingMessages() const { return m_bHasMessages; }
|
bool HasPendingMessages() const { return m_bHasMessages; }
|
||||||
|
|
||||||
// only one sink is active at each moment
|
// only one sink is active at each moment
|
||||||
// get current log target
|
// get current log target, will call wxApp::CreateLogTarget() to create one
|
||||||
|
// if
|
||||||
static wxLog *GetActiveTarget();
|
static wxLog *GetActiveTarget();
|
||||||
// change log target, pLogger = NULL disables logging,
|
// change log target, pLogger = NULL disables logging,
|
||||||
// returns the previous log target
|
// returns the previous log target
|
||||||
@@ -90,6 +91,9 @@ public:
|
|||||||
void SetTimeStampFormat(const char *szTF) { m_szTimeFormat = szTF; }
|
void SetTimeStampFormat(const char *szTF) { m_szTimeFormat = szTF; }
|
||||||
// trace mask (see wxTraceXXX constants for details)
|
// trace mask (see wxTraceXXX constants for details)
|
||||||
static void SetTraceMask(wxTraceMask ulMask) { ms_ulTraceMask = ulMask; }
|
static void SetTraceMask(wxTraceMask ulMask) { ms_ulTraceMask = ulMask; }
|
||||||
|
// should GetActiveTarget() try to create a new log object if the current
|
||||||
|
// is NULL?
|
||||||
|
static void DontCreateOnDemand() { ms_bAutoCreate = FALSE; }
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
// gets the verbose status
|
// gets the verbose status
|
||||||
@@ -120,7 +124,7 @@ private:
|
|||||||
// static variables
|
// static variables
|
||||||
// ----------------
|
// ----------------
|
||||||
static wxLog *ms_pLogger; // currently active log sink
|
static wxLog *ms_pLogger; // currently active log sink
|
||||||
static bool ms_bInitialized; // any log targets created?
|
static bool ms_bAutoCreate; // automatically create new log targets?
|
||||||
static wxTraceMask ms_ulTraceMask; // controls wxLogTrace behaviour
|
static wxTraceMask ms_ulTraceMask; // controls wxLogTrace behaviour
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -39,7 +39,7 @@
|
|||||||
#include <wx/config.h>
|
#include <wx/config.h>
|
||||||
|
|
||||||
// we must include (one of) these files for wxConfigBase::Create
|
// we must include (one of) these files for wxConfigBase::Create
|
||||||
#if defined(__MSWIN__) && defined(wxCONFIG_WIN32_NATIVE)
|
#if defined(__WXMSW__) && defined(wxCONFIG_WIN32_NATIVE)
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
#include <wx/msw/regconf.h>
|
#include <wx/msw/regconf.h>
|
||||||
#else //WIN16
|
#else //WIN16
|
||||||
@@ -57,6 +57,7 @@
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxConfigBase *wxConfigBase::ms_pConfig = NULL;
|
wxConfigBase *wxConfigBase::ms_pConfig = NULL;
|
||||||
|
bool wxConfigBase::ms_bAutoCreate = TRUE;
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
@@ -75,19 +76,23 @@ wxConfigBase *wxConfigBase::Set(wxConfigBase *pConfig)
|
|||||||
|
|
||||||
wxConfigBase *wxConfigBase::Create()
|
wxConfigBase *wxConfigBase::Create()
|
||||||
{
|
{
|
||||||
return ms_pConfig =
|
if ( ms_bAutoCreate && ms_pConfig == NULL ) {
|
||||||
#if defined(__MSWIN__) && defined(wxCONFIG_WIN32_NATIVE)
|
ms_pConfig =
|
||||||
|
#if defined(__WXMSW__) && defined(wxCONFIG_WIN32_NATIVE)
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
new wxRegConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName());
|
new wxRegConfig(wxTheApp->GetVendorName() + '\\'
|
||||||
|
+ wxTheApp->GetAppName());
|
||||||
#else //WIN16
|
#else //WIN16
|
||||||
#error "Sorry, no wxIniConfig yet..."
|
new wxIniConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName());
|
||||||
//new wxIniConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName());
|
|
||||||
#endif
|
#endif
|
||||||
#else // either we're under Unix or wish to use files even under Windows
|
#else // either we're under Unix or wish to use files even under Windows
|
||||||
new wxFileConfig(wxTheApp->GetAppName());
|
new wxFileConfig(wxTheApp->GetAppName());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ms_pConfig;
|
||||||
|
}
|
||||||
|
|
||||||
const char *wxConfigBase::Read(const char *szKey, const char *szDefault) const
|
const char *wxConfigBase::Read(const char *szKey, const char *szDefault) const
|
||||||
{
|
{
|
||||||
static char s_szBuf[1024];
|
static char s_szBuf[1024];
|
||||||
|
@@ -222,16 +222,13 @@ wxFileConfig::wxFileConfig(const wxString& strLocal, const wxString& strGlobal)
|
|||||||
// if the path is not absolute, prepend the standard directory to it
|
// if the path is not absolute, prepend the standard directory to it
|
||||||
|
|
||||||
if ( !strLocal.IsEmpty() && !wxIsPathSeparator(strLocal[0u]) )
|
if ( !strLocal.IsEmpty() && !wxIsPathSeparator(strLocal[0u]) )
|
||||||
{
|
|
||||||
m_strLocalFile = GetLocalDir();
|
m_strLocalFile = GetLocalDir();
|
||||||
m_strLocalFile << strLocal;
|
m_strLocalFile << strLocal;
|
||||||
}
|
|
||||||
|
|
||||||
if ( !strGlobal.IsEmpty() && !wxIsPathSeparator(strGlobal[0u]) )
|
if ( !strGlobal.IsEmpty() && !wxIsPathSeparator(strGlobal[0u]) )
|
||||||
{
|
|
||||||
m_strGlobalFile = GetGlobalDir();
|
m_strGlobalFile = GetGlobalDir();
|
||||||
m_strGlobalFile << strGlobal;
|
m_strGlobalFile << strGlobal;
|
||||||
}
|
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -671,9 +668,6 @@ bool wxFileConfig::DeleteAll()
|
|||||||
{
|
{
|
||||||
CleanUp();
|
CleanUp();
|
||||||
|
|
||||||
m_strLocalFile = m_strGlobalFile = "";
|
|
||||||
Init();
|
|
||||||
|
|
||||||
const char *szFile = m_strLocalFile;
|
const char *szFile = m_strLocalFile;
|
||||||
|
|
||||||
if ( remove(szFile) == -1 )
|
if ( remove(szFile) == -1 )
|
||||||
@@ -683,6 +677,9 @@ bool wxFileConfig::DeleteAll()
|
|||||||
if ( remove(szFile) )
|
if ( remove(szFile) )
|
||||||
wxLogSysError(_("can't delete system configuration file '%s'"), szFile);
|
wxLogSysError(_("can't delete system configuration file '%s'"), szFile);
|
||||||
|
|
||||||
|
m_strLocalFile = m_strGlobalFile = "";
|
||||||
|
Init();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -216,10 +216,12 @@ wxLog::wxLog()
|
|||||||
|
|
||||||
wxLog *wxLog::GetActiveTarget()
|
wxLog *wxLog::GetActiveTarget()
|
||||||
{
|
{
|
||||||
if ( !ms_bInitialized ) {
|
if ( ms_bAutoCreate && ms_pLogger == NULL ) {
|
||||||
// prevent infinite recursion if someone calls wxLogXXX() from
|
// prevent infinite recursion if someone calls wxLogXXX() from
|
||||||
// wxApp::CreateLogTarget()
|
// wxApp::CreateLogTarget()
|
||||||
ms_bInitialized = TRUE;
|
static bool s_bInGetActiveTarget = FALSE;
|
||||||
|
if ( !s_bInGetActiveTarget ) {
|
||||||
|
s_bInGetActiveTarget = TRUE;
|
||||||
|
|
||||||
#ifdef WX_TEST_MINIMAL
|
#ifdef WX_TEST_MINIMAL
|
||||||
ms_pLogger = new wxLogStderr;
|
ms_pLogger = new wxLogStderr;
|
||||||
@@ -230,6 +232,7 @@ wxLog *wxLog::GetActiveTarget()
|
|||||||
|
|
||||||
// do nothing if it fails - what can we do?
|
// do nothing if it fails - what can we do?
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ms_pLogger;
|
return ms_pLogger;
|
||||||
}
|
}
|
||||||
@@ -240,8 +243,6 @@ wxLog *wxLog::SetActiveTarget(wxLog *pLogger)
|
|||||||
if ( ms_pLogger != NULL )
|
if ( ms_pLogger != NULL )
|
||||||
ms_pLogger->Flush();
|
ms_pLogger->Flush();
|
||||||
|
|
||||||
ms_bInitialized = TRUE;
|
|
||||||
|
|
||||||
wxLog *pOldLogger = ms_pLogger;
|
wxLog *pOldLogger = ms_pLogger;
|
||||||
ms_pLogger = pLogger;
|
ms_pLogger = pLogger;
|
||||||
return pOldLogger;
|
return pOldLogger;
|
||||||
@@ -705,7 +706,7 @@ wxLogWindow::~wxLogWindow()
|
|||||||
// static variables
|
// static variables
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
wxLog *wxLog::ms_pLogger = NULL;
|
wxLog *wxLog::ms_pLogger = NULL;
|
||||||
bool wxLog::ms_bInitialized = FALSE;
|
bool wxLog::ms_bAutoCreate = TRUE;
|
||||||
wxTraceMask wxLog::ms_ulTraceMask = (wxTraceMask)0;
|
wxTraceMask wxLog::ms_ulTraceMask = (wxTraceMask)0;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user