From 9977626de47d133617d2525aebe9049754de5374 Mon Sep 17 00:00:00 2001 From: David Elliott Date: Mon, 14 Jul 2003 03:48:20 +0000 Subject: [PATCH] Put OnIdle() back. Without deleting pending objects, frames that have been Destroy()ed (e.g. by the default close implementation) never actually get deleted and thus the program never terminates because the wxTopLevelWindowBase destructor is never called to do ExitMainLoop() FIXME: Why isn't this OnIdle stuff simply in wxAppBase? git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21947 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/cocoa/app.h | 3 +++ src/cocoa/app.mm | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/wx/cocoa/app.h b/include/wx/cocoa/app.h index ac4078563f..02bf4fa5b0 100644 --- a/include/wx/cocoa/app.h +++ b/include/wx/cocoa/app.h @@ -53,6 +53,9 @@ public: virtual bool Yield(bool onlyIfNeeded = FALSE); virtual void WakeUpIdle() { CocoaRequestIdle(); } + /* Idle Processing */ + void OnIdle(wxIdleEvent& event); + virtual bool Initialize(int& argc, wxChar **argv); virtual void CleanUp(); virtual bool CallOnInit(); diff --git a/src/cocoa/app.mm b/src/cocoa/app.mm index baf11a8636..71704b5e28 100644 --- a/src/cocoa/app.mm +++ b/src/cocoa/app.mm @@ -134,6 +134,7 @@ void wxApp::Exit() #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) + EVT_IDLE(wxApp::OnIdle) // EVT_END_SESSION(wxApp::OnEndSession) // EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession) END_EVENT_TABLE() @@ -277,6 +278,37 @@ void wxApp::Dispatch() { } +void wxApp::OnIdle(wxIdleEvent& event) +{ + wxLogDebug("wxApp::OnIdle"); +#if 0 + static bool s_inOnIdle = FALSE; + + // Avoid recursion (via ProcessEvent default case) + if ( s_inOnIdle ) + return; + s_inOnIdle = TRUE; +#endif + + + DeletePendingObjects(); + + // flush the logged messages if any + wxLog *pLog = wxLog::GetActiveTarget(); + if ( pLog != NULL && pLog->HasPendingMessages() ) + pLog->Flush(); + +#if 0 + // Send OnIdle events to all windows + bool needMore = SendIdleEvents(); + + if (needMore) + event.RequestMore(TRUE); + + s_inOnIdle = FALSE; +#endif +} + // Yield to other processes bool wxApp::Yield(bool onlyIfNeeded) -- 2.47.2