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()
|
||||
{
|
||||
static wxConsoleAppTraits s_traitsConsole;
|
||||
wxAppTraits* const traits = (wxTheApp ? wxTheApp->GetTraits() : NULL);
|
||||
wxAppTraits* const traits = GetTraitsIfExists();
|
||||
|
||||
return *(traits ? traits : &s_traitsConsole);
|
||||
}
|
||||
|
@@ -1430,9 +1430,8 @@ wxString wxCmdLineParser::GetUsageString() const
|
||||
count = namesOptions.size();
|
||||
|
||||
// get option names & descriptions for standard options, if any:
|
||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||
wxString stdDesc;
|
||||
if ( traits )
|
||||
if ( wxAppTraits *traits = wxApp::GetTraitsIfExists() )
|
||||
stdDesc = traits->GetStandardCmdLineOptions(namesOptions, descOptions);
|
||||
|
||||
// now construct the detailed help message
|
||||
|
@@ -98,7 +98,7 @@ wxConfigBase *wxConfigBase::Set(wxConfigBase *pConfig)
|
||||
wxConfigBase *wxConfigBase::Create()
|
||||
{
|
||||
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") );
|
||||
|
||||
ms_pConfig = traits->CreateConfig();
|
||||
|
@@ -413,7 +413,7 @@ wxFontMapperBase *wxFontMapperBase::Get()
|
||||
{
|
||||
if ( !sm_instance )
|
||||
{
|
||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||
wxAppTraits *traits = wxApp::GetTraitsIfExists();
|
||||
if ( traits )
|
||||
{
|
||||
sm_instance = traits->CreateFontMapper();
|
||||
|
@@ -892,7 +892,7 @@ void wxLogStderr::DoLogText(const wxString& msg)
|
||||
// simply lost
|
||||
if ( m_fp == stderr )
|
||||
{
|
||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||
wxAppTraits *traits = wxApp::GetTraitsIfExists();
|
||||
if ( traits && !traits->HasStderr() )
|
||||
{
|
||||
wxMessageOutputDebug().Output(msg + wxS('\n'));
|
||||
|
@@ -105,7 +105,7 @@ void wxMessageOutputBest::Output(const wxString& str)
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
// 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;
|
||||
|
||||
if ( !(m_flags & wxMSGOUT_PREFER_MSGBOX) )
|
||||
|
@@ -174,7 +174,7 @@ void wxPlatformInfo::InitForCurrentPlatform()
|
||||
m_initializedForCurrentPlatform = true;
|
||||
|
||||
// autodetect all informations
|
||||
const wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||
const wxAppTraits * const traits = wxApp::GetTraitsIfExists();
|
||||
if ( !traits )
|
||||
{
|
||||
wxFAIL_MSG( wxT("failed to initialize wxPlatformInfo") );
|
||||
|
@@ -65,8 +65,7 @@ private:
|
||||
|
||||
void DoInit()
|
||||
{
|
||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||
if ( traits )
|
||||
if ( wxAppTraits *traits = wxApp::GetTraitsIfExists() )
|
||||
{
|
||||
// ask the traits object to create a renderer for us
|
||||
reset(traits->CreateRenderer());
|
||||
|
@@ -55,7 +55,7 @@ static wxStandardPathsDefault gs_stdPaths;
|
||||
/* static */
|
||||
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") );
|
||||
|
||||
return traits->GetStandardPaths();
|
||||
|
@@ -54,7 +54,7 @@ wxTimer::~wxTimer()
|
||||
|
||||
void wxTimer::Init()
|
||||
{
|
||||
wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||
wxAppTraits * const traits = wxApp::GetTraitsIfExists();
|
||||
m_impl = traits ? traits->CreateTimerImpl(this) : NULL;
|
||||
if ( !m_impl )
|
||||
{
|
||||
|
@@ -1018,7 +1018,7 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler,
|
||||
return pi.dwProcessId;
|
||||
}
|
||||
|
||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||
wxAppTraits *traits = wxApp::GetTraitsIfExists();
|
||||
wxCHECK_MSG( traits, -1, wxT("no wxAppTraits in wxExecute()?") );
|
||||
|
||||
void *cookie = NULL;
|
||||
|
Reference in New Issue
Block a user