From d5f3e1ebf5e10572bd5d388c83e0f8e387cbe423 Mon Sep 17 00:00:00 2001 From: Gilles Depeyrot Date: Sun, 11 May 2003 16:44:48 +0000 Subject: [PATCH] added assert to detect attempt to install idle handler from widget callback not called from main thread git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20583 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/app.cpp | 9 ++++++++- src/gtk1/app.cpp | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 3cb777b959..0d8189fd7c 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -168,6 +168,8 @@ bool wxApp::Yield(bool onlyIfNeeded) // wxWakeUpIdle //----------------------------------------------------------------------------- +static bool gs_WakeUpIdle = false; + void wxWakeUpIdle() { #if wxUSE_THREADS @@ -175,8 +177,11 @@ void wxWakeUpIdle() wxMutexGuiEnter(); #endif - if (g_isIdle) + if (g_isIdle) { + gs_WakeUpIdle = true; wxapp_install_idle_handler(); + gs_WakeUpIdle = false; + } #if wxUSE_THREADS if (!wxThread::IsMain()) @@ -361,6 +366,8 @@ static gint wxapp_poll_func( GPollFD *ufds, guint nfds, gint timeout ) void wxapp_install_idle_handler() { + wxASSERT_MSG( wxThread::IsMain() || gs_WakeUpIdle, wxT("attempt to install idle handler from widget callback in child thread (should be exclusively from wxWakeUpIdle)") ); + wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") ); g_isIdle = FALSE; diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index 3cb777b959..0d8189fd7c 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -168,6 +168,8 @@ bool wxApp::Yield(bool onlyIfNeeded) // wxWakeUpIdle //----------------------------------------------------------------------------- +static bool gs_WakeUpIdle = false; + void wxWakeUpIdle() { #if wxUSE_THREADS @@ -175,8 +177,11 @@ void wxWakeUpIdle() wxMutexGuiEnter(); #endif - if (g_isIdle) + if (g_isIdle) { + gs_WakeUpIdle = true; wxapp_install_idle_handler(); + gs_WakeUpIdle = false; + } #if wxUSE_THREADS if (!wxThread::IsMain()) @@ -361,6 +366,8 @@ static gint wxapp_poll_func( GPollFD *ufds, guint nfds, gint timeout ) void wxapp_install_idle_handler() { + wxASSERT_MSG( wxThread::IsMain() || gs_WakeUpIdle, wxT("attempt to install idle handler from widget callback in child thread (should be exclusively from wxWakeUpIdle)") ); + wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") ); g_isIdle = FALSE; -- 2.45.2