]> git.saurik.com Git - wxWidgets.git/commitdiff
added assert to detect attempt to install idle handler from widget callback
authorGilles Depeyrot <gilles_depeyrot@mac.com>
Sun, 11 May 2003 16:44:48 +0000 (16:44 +0000)
committerGilles Depeyrot <gilles_depeyrot@mac.com>
Sun, 11 May 2003 16:44:48 +0000 (16:44 +0000)
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
src/gtk1/app.cpp

index 3cb777b95939424363166a36bea1388985c4438f..0d8189fd7c5a19e7aab7a692971123f2a06d3125 100644 (file)
@@ -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;
index 3cb777b95939424363166a36bea1388985c4438f..0d8189fd7c5a19e7aab7a692971123f2a06d3125 100644 (file)
@@ -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;