X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/48e5284db6d6f1dab46a81a4ae0d0438ea37bd6e..d23ec02c6ab52f60349601be999bab4cf6acbdc4:/src/common/appcmn.cpp diff --git a/src/common/appcmn.cpp b/src/common/appcmn.cpp index cae7033056..747e7e2ecd 100644 --- a/src/common/appcmn.cpp +++ b/src/common/appcmn.cpp @@ -42,7 +42,6 @@ #include "wx/thread.h" #include "wx/utils.h" #include "wx/ptr_scpd.h" -#include "wx/evtloop.h" #if defined(__WXMSW__) #include "wx/msw/private.h" // includes windows.h for LOGFONT @@ -62,9 +61,7 @@ WX_CHECK_BUILD_OPTIONS("wxCore") // ---------------------------------------------------------------------------- // this defines wxEventLoopPtr -#if wxUSE_EVTLOOP_IN_APP wxDEFINE_TIED_SCOPED_PTR_TYPE(wxEventLoop) -#endif // ============================================================================ // wxAppBase implementation @@ -80,9 +77,7 @@ wxAppBase::wxAppBase() m_useBestVisual = false; m_isActive = true; -#if wxUSE_EVTLOOP_IN_APP m_mainLoop = NULL; -#endif // wxUSE_EVTLOOP_IN_APP // We don't want to exit the app if the user code shows a dialog from its // OnInit() -- but this is what would happen if we set m_exitOnFrameDelete @@ -265,51 +260,37 @@ bool wxAppBase::OnCmdLineParsed(wxCmdLineParser& parser) int wxAppBase::MainLoop() { -#if wxUSE_EVTLOOP_IN_APP wxEventLoopTiedPtr mainLoop(&m_mainLoop, new wxEventLoop); return m_mainLoop->Run(); -#else // !wxUSE_EVTLOOP_IN_APP - return 0; -#endif // wxUSE_EVTLOOP_IN_APP/!wxUSE_EVTLOOP_IN_APP } void wxAppBase::ExitMainLoop() { -#if wxUSE_EVTLOOP_IN_APP // we should exit from the main event loop, not just any currently active // (e.g. modal dialog) event loop if ( m_mainLoop && m_mainLoop->IsRunning() ) { m_mainLoop->Exit(0); } -#endif // wxUSE_EVTLOOP_IN_APP } bool wxAppBase::Pending() { -#if wxUSE_EVTLOOP_IN_APP // 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 // main event loop is not running anyhow wxEventLoop * const loop = wxEventLoop::GetActive(); return loop && loop->Pending(); -#else // wxUSE_EVTLOOP_IN_APP - return false; -#endif // wxUSE_EVTLOOP_IN_APP/!wxUSE_EVTLOOP_IN_APP } bool wxAppBase::Dispatch() { -#if wxUSE_EVTLOOP_IN_APP // see comment in Pending() wxEventLoop * const loop = wxEventLoop::GetActive(); return loop && loop->Dispatch(); -#else // wxUSE_EVTLOOP_IN_APP - return true; -#endif // wxUSE_EVTLOOP_IN_APP/!wxUSE_EVTLOOP_IN_APP } // ---------------------------------------------------------------------------- @@ -375,6 +356,10 @@ void wxAppBase::SetActive(bool active, wxWindow * WXUNUSED(lastFocus)) (void)ProcessEvent(event); } +// ---------------------------------------------------------------------------- +// idle handling +// ---------------------------------------------------------------------------- + void wxAppBase::DeletePendingObjects() { wxList::compatibility_iterator node = wxPendingDelete.GetFirst(); @@ -467,34 +452,19 @@ void wxAppBase::OnIdle(wxIdleEvent& WXUNUSED(event)) } // ---------------------------------------------------------------------------- -// exception handling +// exceptions support // ---------------------------------------------------------------------------- #if wxUSE_EXCEPTIONS -void wxAppBase::HandleEvent(wxEvtHandler *handler, - wxEventFunction func, - wxEvent& event) const +bool wxAppBase::OnExceptionInMainLoop() { - // by default, call wxApp::OnExceptionInMainLoop if an exception occurs - try - { - handler->DoHandleEvent(func, event); - } - catch ( ... ) - { - if ( !wxConstCast(this, wxAppBase)->OnExceptionInMainLoop() ) - { -#if wxUSE_EVTLOOP_IN_APP - wxEventLoop *loop = wxEventLoop::GetActive(); - if ( loop ) - loop->Exit(-1); -#else - wxConstCast(this, wxAppBase)->ExitMainLoop(); + throw; + + // some compilers are too stupid to know that we never return after throw +#if defined(__DMC__) || (defined(_MSC_VER) && _MSC_VER < 1200) + return false; #endif - } - //else: continue running the event loop - } } #endif // wxUSE_EXCEPTIONS