diff --git a/include/wx/gtk/app.h b/include/wx/gtk/app.h index ac36884cfe..38f8a5a5d7 100644 --- a/include/wx/gtk/app.h +++ b/include/wx/gtk/app.h @@ -120,6 +120,10 @@ class wxApp: public wxEvtHandler #endif void DeletePendingObjects(); + /// This can be used to suppress the generation of Idle events. + inline void SuppressIdleEvents(bool arg = TRUE) { m_suppressIdleEvents = arg; } + inline bool GetSuppressIdleEvents() const { return m_suppressIdleEvents; } + bool m_initialized; bool m_exitOnFrameDelete; bool m_wantDebugOutput; @@ -136,7 +140,9 @@ class wxApp: public wxEvtHandler wxString m_className; static wxAppInitializerFunction m_appInitFn; - + private: + /// Set to TRUE while we are in wxYield(). + bool m_suppressIdleEvents; DECLARE_EVENT_TABLE() }; diff --git a/include/wx/gtk1/app.h b/include/wx/gtk1/app.h index ac36884cfe..38f8a5a5d7 100644 --- a/include/wx/gtk1/app.h +++ b/include/wx/gtk1/app.h @@ -120,6 +120,10 @@ class wxApp: public wxEvtHandler #endif void DeletePendingObjects(); + /// This can be used to suppress the generation of Idle events. + inline void SuppressIdleEvents(bool arg = TRUE) { m_suppressIdleEvents = arg; } + inline bool GetSuppressIdleEvents() const { return m_suppressIdleEvents; } + bool m_initialized; bool m_exitOnFrameDelete; bool m_wantDebugOutput; @@ -136,7 +140,9 @@ class wxApp: public wxEvtHandler wxString m_className; static wxAppInitializerFunction m_appInitFn; - + private: + /// Set to TRUE while we are in wxYield(). + bool m_suppressIdleEvents; DECLARE_EVENT_TABLE() }; diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index e37f422742..584837f9c7 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -135,6 +135,9 @@ void wxExit() gtk_main_quit(); } +// forward decl +gint wxapp_idle_callback( gpointer WXUNUSED(data) ); + bool wxYield() { // it's necessary to call ProcessIdle() to update the frames sizes which @@ -148,9 +151,14 @@ bool wxYield() win->OnInternalIdle(); } - while (gtk_events_pending() > 0) + // We need to temporarily remove idle callbacks or the loop will + // never finish. + gtk_idle_remove( wxTheApp->m_idleTag ); + + while (gtk_events_pending()) gtk_main_iteration(); + wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL ); return TRUE; } diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index e37f422742..584837f9c7 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -135,6 +135,9 @@ void wxExit() gtk_main_quit(); } +// forward decl +gint wxapp_idle_callback( gpointer WXUNUSED(data) ); + bool wxYield() { // it's necessary to call ProcessIdle() to update the frames sizes which @@ -148,9 +151,14 @@ bool wxYield() win->OnInternalIdle(); } - while (gtk_events_pending() > 0) + // We need to temporarily remove idle callbacks or the loop will + // never finish. + gtk_idle_remove( wxTheApp->m_idleTag ); + + while (gtk_events_pending()) gtk_main_iteration(); + wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL ); return TRUE; }