Use wxApp::GetTraitsIfExists() wrappers when applicable
This is simpler and more clear than testing wxTheApp explicitly. No real changes.
This commit is contained in:
@@ -358,7 +358,7 @@ wxAppTraits *wxAppConsoleBase::GetTraitsIfExists()
|
|||||||
wxAppTraits& wxAppConsoleBase::GetValidTraits()
|
wxAppTraits& wxAppConsoleBase::GetValidTraits()
|
||||||
{
|
{
|
||||||
static wxConsoleAppTraits s_traitsConsole;
|
static wxConsoleAppTraits s_traitsConsole;
|
||||||
wxAppTraits* const traits = (wxTheApp ? wxTheApp->GetTraits() : NULL);
|
wxAppTraits* const traits = GetTraitsIfExists();
|
||||||
|
|
||||||
return *(traits ? traits : &s_traitsConsole);
|
return *(traits ? traits : &s_traitsConsole);
|
||||||
}
|
}
|
||||||
|
@@ -1430,9 +1430,8 @@ wxString wxCmdLineParser::GetUsageString() const
|
|||||||
count = namesOptions.size();
|
count = namesOptions.size();
|
||||||
|
|
||||||
// get option names & descriptions for standard options, if any:
|
// get option names & descriptions for standard options, if any:
|
||||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
|
||||||
wxString stdDesc;
|
wxString stdDesc;
|
||||||
if ( traits )
|
if ( wxAppTraits *traits = wxApp::GetTraitsIfExists() )
|
||||||
stdDesc = traits->GetStandardCmdLineOptions(namesOptions, descOptions);
|
stdDesc = traits->GetStandardCmdLineOptions(namesOptions, descOptions);
|
||||||
|
|
||||||
// now construct the detailed help message
|
// now construct the detailed help message
|
||||||
|
@@ -98,7 +98,7 @@ wxConfigBase *wxConfigBase::Set(wxConfigBase *pConfig)
|
|||||||
wxConfigBase *wxConfigBase::Create()
|
wxConfigBase *wxConfigBase::Create()
|
||||||
{
|
{
|
||||||
if ( ms_bAutoCreate && ms_pConfig == NULL ) {
|
if ( ms_bAutoCreate && ms_pConfig == NULL ) {
|
||||||
wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
wxAppTraits * const traits = wxApp::GetTraitsIfExists();
|
||||||
wxCHECK_MSG( traits, NULL, wxT("create wxApp before calling this") );
|
wxCHECK_MSG( traits, NULL, wxT("create wxApp before calling this") );
|
||||||
|
|
||||||
ms_pConfig = traits->CreateConfig();
|
ms_pConfig = traits->CreateConfig();
|
||||||
|
@@ -413,7 +413,7 @@ wxFontMapperBase *wxFontMapperBase::Get()
|
|||||||
{
|
{
|
||||||
if ( !sm_instance )
|
if ( !sm_instance )
|
||||||
{
|
{
|
||||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
wxAppTraits *traits = wxApp::GetTraitsIfExists();
|
||||||
if ( traits )
|
if ( traits )
|
||||||
{
|
{
|
||||||
sm_instance = traits->CreateFontMapper();
|
sm_instance = traits->CreateFontMapper();
|
||||||
|
@@ -892,7 +892,7 @@ void wxLogStderr::DoLogText(const wxString& msg)
|
|||||||
// simply lost
|
// simply lost
|
||||||
if ( m_fp == stderr )
|
if ( m_fp == stderr )
|
||||||
{
|
{
|
||||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
wxAppTraits *traits = wxApp::GetTraitsIfExists();
|
||||||
if ( traits && !traits->HasStderr() )
|
if ( traits && !traits->HasStderr() )
|
||||||
{
|
{
|
||||||
wxMessageOutputDebug().Output(msg + wxS('\n'));
|
wxMessageOutputDebug().Output(msg + wxS('\n'));
|
||||||
|
@@ -105,7 +105,7 @@ void wxMessageOutputBest::Output(const wxString& str)
|
|||||||
{
|
{
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
// decide whether to use console output or not
|
// decide whether to use console output or not
|
||||||
wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
wxAppTraits * const traits = wxApp::GetTraitsIfExists();
|
||||||
const bool hasStderr = traits ? traits->CanUseStderr() : false;
|
const bool hasStderr = traits ? traits->CanUseStderr() : false;
|
||||||
|
|
||||||
if ( !(m_flags & wxMSGOUT_PREFER_MSGBOX) )
|
if ( !(m_flags & wxMSGOUT_PREFER_MSGBOX) )
|
||||||
|
@@ -174,7 +174,7 @@ void wxPlatformInfo::InitForCurrentPlatform()
|
|||||||
m_initializedForCurrentPlatform = true;
|
m_initializedForCurrentPlatform = true;
|
||||||
|
|
||||||
// autodetect all informations
|
// autodetect all informations
|
||||||
const wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
const wxAppTraits * const traits = wxApp::GetTraitsIfExists();
|
||||||
if ( !traits )
|
if ( !traits )
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( wxT("failed to initialize wxPlatformInfo") );
|
wxFAIL_MSG( wxT("failed to initialize wxPlatformInfo") );
|
||||||
|
@@ -65,8 +65,7 @@ private:
|
|||||||
|
|
||||||
void DoInit()
|
void DoInit()
|
||||||
{
|
{
|
||||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
if ( wxAppTraits *traits = wxApp::GetTraitsIfExists() )
|
||||||
if ( traits )
|
|
||||||
{
|
{
|
||||||
// ask the traits object to create a renderer for us
|
// ask the traits object to create a renderer for us
|
||||||
reset(traits->CreateRenderer());
|
reset(traits->CreateRenderer());
|
||||||
|
@@ -55,7 +55,7 @@ static wxStandardPathsDefault gs_stdPaths;
|
|||||||
/* static */
|
/* static */
|
||||||
wxStandardPaths& wxStandardPathsBase::Get()
|
wxStandardPaths& wxStandardPathsBase::Get()
|
||||||
{
|
{
|
||||||
wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
wxAppTraits * const traits = wxApp::GetTraitsIfExists();
|
||||||
wxCHECK_MSG( traits, gs_stdPaths, wxT("create wxApp before calling this") );
|
wxCHECK_MSG( traits, gs_stdPaths, wxT("create wxApp before calling this") );
|
||||||
|
|
||||||
return traits->GetStandardPaths();
|
return traits->GetStandardPaths();
|
||||||
|
@@ -54,7 +54,7 @@ wxTimer::~wxTimer()
|
|||||||
|
|
||||||
void wxTimer::Init()
|
void wxTimer::Init()
|
||||||
{
|
{
|
||||||
wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
wxAppTraits * const traits = wxApp::GetTraitsIfExists();
|
||||||
m_impl = traits ? traits->CreateTimerImpl(this) : NULL;
|
m_impl = traits ? traits->CreateTimerImpl(this) : NULL;
|
||||||
if ( !m_impl )
|
if ( !m_impl )
|
||||||
{
|
{
|
||||||
|
@@ -1018,7 +1018,7 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler,
|
|||||||
return pi.dwProcessId;
|
return pi.dwProcessId;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
wxAppTraits *traits = wxApp::GetTraitsIfExists();
|
||||||
wxCHECK_MSG( traits, -1, wxT("no wxAppTraits in wxExecute()?") );
|
wxCHECK_MSG( traits, -1, wxT("no wxAppTraits in wxExecute()?") );
|
||||||
|
|
||||||
void *cookie = NULL;
|
void *cookie = NULL;
|
||||||
|
Reference in New Issue
Block a user