more wxPostEvent MT fixes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30508 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2004-11-12 21:44:26 +00:00
parent 281818319b
commit c263eb0384
4 changed files with 34 additions and 30 deletions

View File

@ -133,13 +133,9 @@ bool wxApp::Yield(bool onlyIfNeeded)
wxIsInsideYield = TRUE; wxIsInsideYield = TRUE;
if (!g_isIdle) // We need to remove idle callbacks or the loop will
{ // never finish.
// We need to remove idle callbacks or the loop will wxTheApp->RemoveIdleTag();
// never finish.
wxTheApp->RemoveIdleTag();
g_isIdle = TRUE;
}
// disable log flushing from here because a call to wxYield() shouldn't // disable log flushing from here because a call to wxYield() shouldn't
// normally result in message boxes popping up &c // normally result in message boxes popping up &c
@ -184,8 +180,7 @@ void wxApp::WakeUpIdle()
#endif // wxUSE_THREADS_ #endif // wxUSE_THREADS_
#endif // __WXGTK2__ #endif // __WXGTK2__
if (g_isIdle) wxapp_install_idle_handler();
wxapp_install_idle_handler();
#ifndef __WXGTK20__ #ifndef __WXGTK20__
#if wxUSE_THREADS #if wxUSE_THREADS
@ -386,6 +381,11 @@ void wxapp_install_idle_handler()
wxMutexLocker lock(gs_idleTagsMutex); wxMutexLocker lock(gs_idleTagsMutex);
#endif #endif
// Don't install the handler if it's already installed. This test *MUST*
// be done when gs_idleTagsMutex is locked!
if (!g_isIdle)
return;
// GD: this assert is raised when using the thread sample (which works) // GD: this assert is raised when using the thread sample (which works)
// so the test is probably not so easy. Can widget callbacks be // so the test is probably not so easy. Can widget callbacks be
// triggered from child threads and, if so, for which widgets? // triggered from child threads and, if so, for which widgets?
@ -437,6 +437,7 @@ wxApp::wxApp()
#endif // __WXDEBUG__ #endif // __WXDEBUG__
m_idleTag = 0; m_idleTag = 0;
g_isIdle = TRUE;
wxapp_install_idle_handler(); wxapp_install_idle_handler();
#if wxUSE_THREADS #if wxUSE_THREADS
@ -702,6 +703,10 @@ void wxApp::RemoveIdleTag()
#if wxUSE_THREADS #if wxUSE_THREADS
wxMutexLocker lock(gs_idleTagsMutex); wxMutexLocker lock(gs_idleTagsMutex);
#endif #endif
gtk_idle_remove( wxTheApp->m_idleTag ); if (!g_isIdle)
wxTheApp->m_idleTag = 0; {
gtk_idle_remove( wxTheApp->m_idleTag );
wxTheApp->m_idleTag = 0;
g_isIdle = TRUE;
}
} }

View File

@ -101,16 +101,13 @@ void wxEventLoop::Exit(int rc)
// wxEventLoop message processing dispatching // wxEventLoop message processing dispatching
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
extern bool g_isIdle;
bool wxEventLoop::Pending() const bool wxEventLoop::Pending() const
{ {
if (wxTheApp && !g_isIdle) if (wxTheApp)
{ {
// We need to remove idle callbacks or gtk_events_pending will // We need to remove idle callbacks or gtk_events_pending will
// never return false. // never return false.
wxTheApp->RemoveIdleTag(); wxTheApp->RemoveIdleTag();
g_isIdle = TRUE;
} }
return gtk_events_pending(); return gtk_events_pending();

View File

@ -133,13 +133,9 @@ bool wxApp::Yield(bool onlyIfNeeded)
wxIsInsideYield = TRUE; wxIsInsideYield = TRUE;
if (!g_isIdle) // We need to remove idle callbacks or the loop will
{ // never finish.
// We need to remove idle callbacks or the loop will wxTheApp->RemoveIdleTag();
// never finish.
wxTheApp->RemoveIdleTag();
g_isIdle = TRUE;
}
// disable log flushing from here because a call to wxYield() shouldn't // disable log flushing from here because a call to wxYield() shouldn't
// normally result in message boxes popping up &c // normally result in message boxes popping up &c
@ -184,8 +180,7 @@ void wxApp::WakeUpIdle()
#endif // wxUSE_THREADS_ #endif // wxUSE_THREADS_
#endif // __WXGTK2__ #endif // __WXGTK2__
if (g_isIdle) wxapp_install_idle_handler();
wxapp_install_idle_handler();
#ifndef __WXGTK20__ #ifndef __WXGTK20__
#if wxUSE_THREADS #if wxUSE_THREADS
@ -386,6 +381,11 @@ void wxapp_install_idle_handler()
wxMutexLocker lock(gs_idleTagsMutex); wxMutexLocker lock(gs_idleTagsMutex);
#endif #endif
// Don't install the handler if it's already installed. This test *MUST*
// be done when gs_idleTagsMutex is locked!
if (!g_isIdle)
return;
// GD: this assert is raised when using the thread sample (which works) // GD: this assert is raised when using the thread sample (which works)
// so the test is probably not so easy. Can widget callbacks be // so the test is probably not so easy. Can widget callbacks be
// triggered from child threads and, if so, for which widgets? // triggered from child threads and, if so, for which widgets?
@ -437,6 +437,7 @@ wxApp::wxApp()
#endif // __WXDEBUG__ #endif // __WXDEBUG__
m_idleTag = 0; m_idleTag = 0;
g_isIdle = TRUE;
wxapp_install_idle_handler(); wxapp_install_idle_handler();
#if wxUSE_THREADS #if wxUSE_THREADS
@ -702,6 +703,10 @@ void wxApp::RemoveIdleTag()
#if wxUSE_THREADS #if wxUSE_THREADS
wxMutexLocker lock(gs_idleTagsMutex); wxMutexLocker lock(gs_idleTagsMutex);
#endif #endif
gtk_idle_remove( wxTheApp->m_idleTag ); if (!g_isIdle)
wxTheApp->m_idleTag = 0; {
gtk_idle_remove( wxTheApp->m_idleTag );
wxTheApp->m_idleTag = 0;
g_isIdle = TRUE;
}
} }

View File

@ -101,16 +101,13 @@ void wxEventLoop::Exit(int rc)
// wxEventLoop message processing dispatching // wxEventLoop message processing dispatching
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
extern bool g_isIdle;
bool wxEventLoop::Pending() const bool wxEventLoop::Pending() const
{ {
if (wxTheApp && !g_isIdle) if (wxTheApp)
{ {
// We need to remove idle callbacks or gtk_events_pending will // We need to remove idle callbacks or gtk_events_pending will
// never return false. // never return false.
wxTheApp->RemoveIdleTag(); wxTheApp->RemoveIdleTag();
g_isIdle = TRUE;
} }
return gtk_events_pending(); return gtk_events_pending();