rename old wxAppConsole to wxAppConsoleBase and wxAppConsoleUnix to wxAppConsole for consistency with wxAppBase/wxApp and to fix the bug 1729377 (crash when using timers under Unix in console app); also #define wxApp as wxAppConsole instead of declaring it as a real class in console build to avoid problems with ODR violation
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46325 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/common/appbase.cpp
|
||||
// Purpose: implements wxAppConsole class
|
||||
// Purpose: implements wxAppConsoleBase class
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 19.06.2003 (extracted from common/appcmn.cpp)
|
||||
@@ -110,9 +110,9 @@
|
||||
// global vars
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxAppConsole *wxAppConsole::ms_appInstance = NULL;
|
||||
wxAppConsole *wxAppConsoleBase::ms_appInstance = NULL;
|
||||
|
||||
wxAppInitializerFunction wxAppConsole::ms_appInitFn = NULL;
|
||||
wxAppInitializerFunction wxAppConsoleBase::ms_appInitFn = NULL;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxEventLoopPtr
|
||||
@@ -122,19 +122,19 @@ wxAppInitializerFunction wxAppConsole::ms_appInitFn = NULL;
|
||||
wxDEFINE_TIED_SCOPED_PTR_TYPE(wxEventLoopBase)
|
||||
|
||||
// ============================================================================
|
||||
// wxAppConsole implementation
|
||||
// wxAppConsoleBase implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ctor/dtor
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxAppConsole::wxAppConsole()
|
||||
wxAppConsoleBase::wxAppConsoleBase()
|
||||
{
|
||||
m_traits = NULL;
|
||||
m_mainLoop = NULL;
|
||||
|
||||
ms_appInstance = this;
|
||||
ms_appInstance = wx_static_cast(wxAppConsole *, this);
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
SetTraceMasks();
|
||||
@@ -148,7 +148,7 @@ wxAppConsole::wxAppConsole()
|
||||
#endif
|
||||
}
|
||||
|
||||
wxAppConsole::~wxAppConsole()
|
||||
wxAppConsoleBase::~wxAppConsoleBase()
|
||||
{
|
||||
delete m_traits;
|
||||
}
|
||||
@@ -157,7 +157,7 @@ wxAppConsole::~wxAppConsole()
|
||||
// initilization/cleanup
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxAppConsole::Initialize(int& argcOrig, wxChar **argvOrig)
|
||||
bool wxAppConsoleBase::Initialize(int& argcOrig, wxChar **argvOrig)
|
||||
{
|
||||
#if wxUSE_INTL
|
||||
GetTraits()->SetLocale();
|
||||
@@ -182,12 +182,12 @@ bool wxAppConsole::Initialize(int& argcOrig, wxChar **argvOrig)
|
||||
return true;
|
||||
}
|
||||
|
||||
wxEventLoopBase *wxAppConsole::CreateMainLoop()
|
||||
wxEventLoopBase *wxAppConsoleBase::CreateMainLoop()
|
||||
{
|
||||
return GetTraits()->CreateEventLoop();
|
||||
}
|
||||
|
||||
void wxAppConsole::CleanUp()
|
||||
void wxAppConsoleBase::CleanUp()
|
||||
{
|
||||
if ( m_mainLoop )
|
||||
{
|
||||
@@ -208,7 +208,7 @@ void wxAppConsole::CleanUp()
|
||||
// OnXXX() callbacks
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxAppConsole::OnInit()
|
||||
bool wxAppConsoleBase::OnInit()
|
||||
{
|
||||
#if wxUSE_CMDLINE_PARSER
|
||||
wxCmdLineParser parser(argc, argv);
|
||||
@@ -238,12 +238,12 @@ bool wxAppConsole::OnInit()
|
||||
return true;
|
||||
}
|
||||
|
||||
int wxAppConsole::OnRun()
|
||||
int wxAppConsoleBase::OnRun()
|
||||
{
|
||||
return MainLoop();
|
||||
}
|
||||
|
||||
int wxAppConsole::OnExit()
|
||||
int wxAppConsoleBase::OnExit()
|
||||
{
|
||||
#if wxUSE_CONFIG
|
||||
// delete the config object if any (don't use Get() here, but Set()
|
||||
@@ -254,7 +254,7 @@ int wxAppConsole::OnExit()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wxAppConsole::Exit()
|
||||
void wxAppConsoleBase::Exit()
|
||||
{
|
||||
if (m_mainLoop != NULL)
|
||||
ExitMainLoop();
|
||||
@@ -266,12 +266,12 @@ void wxAppConsole::Exit()
|
||||
// traits stuff
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxAppTraits *wxAppConsole::CreateTraits()
|
||||
wxAppTraits *wxAppConsoleBase::CreateTraits()
|
||||
{
|
||||
return new wxConsoleAppTraits;
|
||||
}
|
||||
|
||||
wxAppTraits *wxAppConsole::GetTraits()
|
||||
wxAppTraits *wxAppConsoleBase::GetTraits()
|
||||
{
|
||||
// FIXME-MT: protect this with a CS?
|
||||
if ( !m_traits )
|
||||
@@ -288,14 +288,14 @@ wxAppTraits *wxAppConsole::GetTraits()
|
||||
// event processing
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int wxAppConsole::MainLoop()
|
||||
int wxAppConsoleBase::MainLoop()
|
||||
{
|
||||
wxEventLoopBaseTiedPtr mainLoop(&m_mainLoop, CreateMainLoop());
|
||||
|
||||
return m_mainLoop ? m_mainLoop->Run() : -1;
|
||||
}
|
||||
|
||||
void wxAppConsole::ExitMainLoop()
|
||||
void wxAppConsoleBase::ExitMainLoop()
|
||||
{
|
||||
// we should exit from the main event loop, not just any currently active
|
||||
// (e.g. modal dialog) event loop
|
||||
@@ -305,7 +305,7 @@ void wxAppConsole::ExitMainLoop()
|
||||
}
|
||||
}
|
||||
|
||||
bool wxAppConsole::Pending()
|
||||
bool wxAppConsoleBase::Pending()
|
||||
{
|
||||
// use the currently active message loop here, not m_mainLoop, because if
|
||||
// we're showing a modal dialog (with its own event loop) currently the
|
||||
@@ -315,7 +315,7 @@ bool wxAppConsole::Pending()
|
||||
return loop && loop->Pending();
|
||||
}
|
||||
|
||||
bool wxAppConsole::Dispatch()
|
||||
bool wxAppConsoleBase::Dispatch()
|
||||
{
|
||||
// see comment in Pending()
|
||||
wxEventLoopBase * const loop = wxEventLoopBase::GetActive();
|
||||
@@ -323,7 +323,7 @@ bool wxAppConsole::Dispatch()
|
||||
return loop && loop->Dispatch();
|
||||
}
|
||||
|
||||
bool wxAppConsole::HasPendingEvents() const
|
||||
bool wxAppConsoleBase::HasPendingEvents() const
|
||||
{
|
||||
// ensure that we're the only thread to modify the pending events list
|
||||
wxENTER_CRIT_SECT( *wxPendingEventsLocker );
|
||||
@@ -337,7 +337,15 @@ bool wxAppConsole::HasPendingEvents() const
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxAppConsole::ProcessPendingEvents()
|
||||
/* static */
|
||||
bool wxAppConsoleBase::IsMainLoopRunning()
|
||||
{
|
||||
const wxAppConsole * const app = GetInstance();
|
||||
|
||||
return app && app->m_mainLoop != NULL;
|
||||
}
|
||||
|
||||
void wxAppConsoleBase::ProcessPendingEvents()
|
||||
{
|
||||
#if wxUSE_THREADS
|
||||
if ( !wxPendingEventsLocker )
|
||||
@@ -370,13 +378,13 @@ void wxAppConsole::ProcessPendingEvents()
|
||||
wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
|
||||
}
|
||||
|
||||
void wxAppConsole::WakeUpIdle()
|
||||
void wxAppConsoleBase::WakeUpIdle()
|
||||
{
|
||||
if ( m_mainLoop )
|
||||
m_mainLoop->WakeUp();
|
||||
}
|
||||
|
||||
bool wxAppConsole::ProcessIdle()
|
||||
bool wxAppConsoleBase::ProcessIdle()
|
||||
{
|
||||
wxIdleEvent event;
|
||||
|
||||
@@ -385,7 +393,7 @@ bool wxAppConsole::ProcessIdle()
|
||||
return event.MoreRequested();
|
||||
}
|
||||
|
||||
int wxAppConsole::FilterEvent(wxEvent& WXUNUSED(event))
|
||||
int wxAppConsoleBase::FilterEvent(wxEvent& WXUNUSED(event))
|
||||
{
|
||||
// process the events normally by default
|
||||
return -1;
|
||||
@@ -398,9 +406,9 @@ int wxAppConsole::FilterEvent(wxEvent& WXUNUSED(event))
|
||||
#if wxUSE_EXCEPTIONS
|
||||
|
||||
void
|
||||
wxAppConsole::HandleEvent(wxEvtHandler *handler,
|
||||
wxEventFunction func,
|
||||
wxEvent& event) const
|
||||
wxAppConsoleBase::HandleEvent(wxEvtHandler *handler,
|
||||
wxEventFunction func,
|
||||
wxEvent& event) const
|
||||
{
|
||||
// by default, simply call the handler
|
||||
(handler->*func)(event);
|
||||
@@ -412,7 +420,7 @@ wxAppConsole::HandleEvent(wxEvtHandler *handler,
|
||||
|
||||
#if wxUSE_EXCEPTIONS
|
||||
|
||||
bool wxAppConsole::OnExceptionInMainLoop()
|
||||
bool wxAppConsoleBase::OnExceptionInMainLoop()
|
||||
{
|
||||
throw;
|
||||
|
||||
@@ -435,7 +443,7 @@ bool wxAppConsole::OnExceptionInMainLoop()
|
||||
|
||||
#define OPTION_VERBOSE _T("verbose")
|
||||
|
||||
void wxAppConsole::OnInitCmdLine(wxCmdLineParser& parser)
|
||||
void wxAppConsoleBase::OnInitCmdLine(wxCmdLineParser& parser)
|
||||
{
|
||||
// the standard command line options
|
||||
static const wxCmdLineEntryDesc cmdLineDesc[] =
|
||||
@@ -474,7 +482,7 @@ void wxAppConsole::OnInitCmdLine(wxCmdLineParser& parser)
|
||||
parser.SetDesc(cmdLineDesc);
|
||||
}
|
||||
|
||||
bool wxAppConsole::OnCmdLineParsed(wxCmdLineParser& parser)
|
||||
bool wxAppConsoleBase::OnCmdLineParsed(wxCmdLineParser& parser)
|
||||
{
|
||||
#if wxUSE_LOG
|
||||
if ( parser.Found(OPTION_VERBOSE) )
|
||||
@@ -488,14 +496,14 @@ bool wxAppConsole::OnCmdLineParsed(wxCmdLineParser& parser)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxAppConsole::OnCmdLineHelp(wxCmdLineParser& parser)
|
||||
bool wxAppConsoleBase::OnCmdLineHelp(wxCmdLineParser& parser)
|
||||
{
|
||||
parser.Usage();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxAppConsole::OnCmdLineError(wxCmdLineParser& parser)
|
||||
bool wxAppConsoleBase::OnCmdLineError(wxCmdLineParser& parser)
|
||||
{
|
||||
parser.Usage();
|
||||
|
||||
@@ -509,8 +517,8 @@ bool wxAppConsole::OnCmdLineError(wxCmdLineParser& parser)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/* static */
|
||||
bool wxAppConsole::CheckBuildOptions(const char *optionsSignature,
|
||||
const char *componentName)
|
||||
bool wxAppConsoleBase::CheckBuildOptions(const char *optionsSignature,
|
||||
const char *componentName)
|
||||
{
|
||||
#if 0 // can't use wxLogTrace, not up and running yet
|
||||
printf("checking build options object '%s' (ptr %p) in '%s'\n",
|
||||
@@ -539,19 +547,19 @@ bool wxAppConsole::CheckBuildOptions(const char *optionsSignature,
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
|
||||
void wxAppConsole::OnAssertFailure(const wxChar *file,
|
||||
int line,
|
||||
const wxChar *func,
|
||||
const wxChar *cond,
|
||||
const wxChar *msg)
|
||||
void wxAppConsoleBase::OnAssertFailure(const wxChar *file,
|
||||
int line,
|
||||
const wxChar *func,
|
||||
const wxChar *cond,
|
||||
const wxChar *msg)
|
||||
{
|
||||
ShowAssertDialog(file, line, func, cond, msg, GetTraits());
|
||||
}
|
||||
|
||||
void wxAppConsole::OnAssert(const wxChar *file,
|
||||
int line,
|
||||
const wxChar *cond,
|
||||
const wxChar *msg)
|
||||
void wxAppConsoleBase::OnAssert(const wxChar *file,
|
||||
int line,
|
||||
const wxChar *cond,
|
||||
const wxChar *msg)
|
||||
{
|
||||
OnAssertFailure(file, line, NULL, cond, msg);
|
||||
}
|
||||
|
Reference in New Issue
Block a user