// if the thread we're waiting for is waiting for the GUI mutex, we will
// deadlock so make sure we release it temporarily
if ( wxThread::IsMain() )
- wxMutexGuiLeave();
+ {
+ // give the thread we're waiting for chance to do the GUI call
+ // it might be in, we don't do this conditionally as the to be waited on
+ // thread might have to acquire the mutex later but before terminating
+ if ( wxGuiOwnedByMainThread() )
+ {
+ wxMutexGuiLeave();
+ }
+ }
{
wxCriticalSectionLocker lock(m_csJoinFlag);
m_shouldBeJoined = FALSE;
}
}
-
- // reacquire GUI mutex
- if ( wxThread::IsMain() )
- wxMutexGuiEnter();
}
void wxThreadInternal::Pause()
bool wxThread::IsMain()
{
- return GetCurrentId() == gs_idMainThread || gs_idMainThread == kNoThreadID;
+ return GetCurrentId() == gs_idMainThread || gs_idMainThread == kInvalidID ;
}
#ifdef Yield
*rc = m_internal->GetExitCode();
}
}
- //else: can't wait for detached threads
}
return wxTHREAD_NO_ERROR;