fix WakeUpIdle() when called from another thread while idle processing is in progress
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72829 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -143,29 +143,26 @@ bool wxApp::DoIdle()
|
|||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
wxMutexLocker lock(m_idleMutex);
|
wxMutexLocker lock(m_idleMutex);
|
||||||
#endif
|
#endif
|
||||||
// if a new idle source was added during ProcessIdle
|
|
||||||
if (m_idleSourceId != 0)
|
|
||||||
{
|
|
||||||
// remove it
|
|
||||||
g_source_remove(m_idleSourceId);
|
|
||||||
m_idleSourceId = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pending events can be added asynchronously,
|
bool keepSource = false;
|
||||||
// need to keep idle source if any have appeared
|
// if a new idle source has not been added, either as a result of idle
|
||||||
if (HasPendingEvents())
|
// processing above or by another thread calling WakeUpIdle()
|
||||||
needMore = true;
|
if (m_idleSourceId == 0)
|
||||||
|
|
||||||
// if more idle processing requested
|
|
||||||
if (needMore)
|
|
||||||
{
|
{
|
||||||
// keep this source installed
|
// if more idle processing was requested or pending events have appeared
|
||||||
m_idleSourceId = id_save;
|
if (needMore || HasPendingEvents())
|
||||||
return true;
|
{
|
||||||
|
// keep this source installed
|
||||||
|
m_idleSourceId = id_save;
|
||||||
|
keepSource = true;
|
||||||
|
}
|
||||||
|
else // add hooks and remove this source
|
||||||
|
wx_add_idle_hooks();
|
||||||
}
|
}
|
||||||
// add hooks and remove this source
|
// else remove this source, leave new one installed
|
||||||
wx_add_idle_hooks();
|
// we must keep an idle source, otherwise a wakeup could be lost
|
||||||
return false;
|
|
||||||
|
return keepSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user