]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/appcmn.cpp
fixed (recently reintroduced) activation bug when the modal dialog was dismissed
[wxWidgets.git] / src / common / appcmn.cpp
index 7bb287317799ff1160449aaaadf1943ee88cf860..d3d562d3e6324f41f1e23838a453e4dbbc1eabe6 100644 (file)
@@ -65,23 +65,7 @@ WX_CHECK_BUILD_OPTIONS("wxCore")
 // ----------------------------------------------------------------------------
 
 // this defines wxEventLoopPtr
-wxDEFINE_SCOPED_PTR_TYPE(wxEventLoop);
-
-// but we need a smart pointer tied to wxAppBase::m_mainLoop, so we define
-// another helper class
-class wxTiedEventLoopPtr : public wxEventLoopPtr
-{
-public:
-    wxTiedEventLoopPtr(wxEventLoop **ppEvtLoop, wxEventLoop *pLoop)
-        : wxEventLoopPtr(*ppEvtLoop = pLoop), m_ppEvtLoop(ppEvtLoop)
-        {
-        }
-
-    ~wxTiedEventLoopPtr() { *m_ppEvtLoop = NULL; }
-
-private:
-    wxEventLoop **m_ppEvtLoop;
-};
+wxDEFINE_TIED_SCOPED_PTR_TYPE(wxEventLoop);
 
 // ============================================================================
 // wxAppBase implementation
@@ -97,7 +81,9 @@ 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
@@ -270,37 +256,51 @@ bool wxAppBase::OnCmdLineParsed(wxCmdLineParser& parser)
 
 int wxAppBase::MainLoop()
 {
-    wxTiedEventLoopPtr mainLoop(&m_mainLoop, new wxEventLoop);
+#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->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() : true;
+    return loop && loop->Dispatch();
+#else // wxUSE_EVTLOOP_IN_APP
+    return true;
+#endif // wxUSE_EVTLOOP_IN_APP/!wxUSE_EVTLOOP_IN_APP
 }
 
 // ----------------------------------------------------------------------------