From 99ba739f6ab3c688ded3e8a4be4d4f9fccf03520 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Thu, 11 Jan 2001 18:54:10 +0000 Subject: [PATCH] wxYield() patch from stable tree. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9079 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/app.cpp | 30 ++++++++++++++++++------------ src/gtk1/app.cpp | 30 ++++++++++++++++++------------ 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 76a9bc3dd7..5db09e1359 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -82,25 +82,27 @@ void wxExit() bool wxYield() { - bool has_idle = (wxTheApp->m_idleTag != 0); +#ifdef __WXDEBUG__ + static bool s_inYield = FALSE; + + if (s_inYield) + wxFAIL_MSG( wxT("wxYield called recursively" ) ); + + s_inYield = TRUE; +#endif - if (has_idle) + if (!g_isIdle) { - /* We need to temporarily remove idle callbacks or the loop will - never finish. */ + // We need to remove idle callbacks or the loop will + // never finish. gtk_idle_remove( wxTheApp->m_idleTag ); wxTheApp->m_idleTag = 0; + g_isIdle = TRUE; } while (gtk_events_pending()) gtk_main_iteration(); - if (has_idle) - { - /* re-add idle handler (very low priority) */ - wxTheApp->m_idleTag = gtk_idle_add_priority( 1000, wxapp_idle_callback, (gpointer) NULL ); - } - // disable log flushing from here because a call to wxYield() shouldn't // normally result in message boxes popping up &c wxLog::Suspend(); @@ -113,6 +115,10 @@ bool wxYield() // let the logs be flashed again wxLog::Resume(); +#ifdef __WXDEBUG__ + s_inYield = FALSE; +#endif + return TRUE; } @@ -199,6 +205,8 @@ void wxapp_install_idle_handler() { wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") ); + g_isIdle = FALSE; + if (g_pendingTag == 0) g_pendingTag = gtk_idle_add_priority( 900, wxapp_pending_callback, (gpointer) NULL ); @@ -209,8 +217,6 @@ void wxapp_install_idle_handler() idle time). Very low priority. */ wxTheApp->m_idleTag = gtk_idle_add_priority( 1000, wxapp_idle_callback, (gpointer) NULL ); - - g_isIdle = FALSE; } #if wxUSE_THREADS diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index 76a9bc3dd7..5db09e1359 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -82,25 +82,27 @@ void wxExit() bool wxYield() { - bool has_idle = (wxTheApp->m_idleTag != 0); +#ifdef __WXDEBUG__ + static bool s_inYield = FALSE; + + if (s_inYield) + wxFAIL_MSG( wxT("wxYield called recursively" ) ); + + s_inYield = TRUE; +#endif - if (has_idle) + if (!g_isIdle) { - /* We need to temporarily remove idle callbacks or the loop will - never finish. */ + // We need to remove idle callbacks or the loop will + // never finish. gtk_idle_remove( wxTheApp->m_idleTag ); wxTheApp->m_idleTag = 0; + g_isIdle = TRUE; } while (gtk_events_pending()) gtk_main_iteration(); - if (has_idle) - { - /* re-add idle handler (very low priority) */ - wxTheApp->m_idleTag = gtk_idle_add_priority( 1000, wxapp_idle_callback, (gpointer) NULL ); - } - // disable log flushing from here because a call to wxYield() shouldn't // normally result in message boxes popping up &c wxLog::Suspend(); @@ -113,6 +115,10 @@ bool wxYield() // let the logs be flashed again wxLog::Resume(); +#ifdef __WXDEBUG__ + s_inYield = FALSE; +#endif + return TRUE; } @@ -199,6 +205,8 @@ void wxapp_install_idle_handler() { wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") ); + g_isIdle = FALSE; + if (g_pendingTag == 0) g_pendingTag = gtk_idle_add_priority( 900, wxapp_pending_callback, (gpointer) NULL ); @@ -209,8 +217,6 @@ void wxapp_install_idle_handler() idle time). Very low priority. */ wxTheApp->m_idleTag = gtk_idle_add_priority( 1000, wxapp_idle_callback, (gpointer) NULL ); - - g_isIdle = FALSE; } #if wxUSE_THREADS -- 2.45.2