MPQueueID m_notifyQueueId; // its notification queue
wxThreadState m_state; // see wxThreadState enum
- int m_prio; // in wxWindows units: from 0 to 100
+ int m_prio; // in wxWidgets units: from 0 to 100
// this flag is set when the thread should terminate
bool m_cancelled;
if ( m_tid)
{
// Mac priorities range from 1 to 10,000, with a default of 100.
- // wxWindows priorities range from 0 to 100 with a default of 50.
- // We can map wxWindows to Mac priorities easily by assuming
+ // wxWidgets priorities range from 0 to 100 with a default of 50.
+ // We can map wxWidgets to Mac priorities easily by assuming
// the former uses a logarithmic scale.
const unsigned int macPriority = ( int)( exp( priority / 25.0 * log( 10.0)) + 0.5);
// 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;
+ return GetCurrentId() == gs_idMainThread || gs_idMainThread == kInvalidID ;
}
#ifdef Yield
*rc = m_internal->GetExitCode();
}
}
- //else: can't wait for detached threads
}
return wxTHREAD_NO_ERROR;
// m_critsect on us (almost all of them do)
OnExit();
- MPTerminateTask( m_internal->GetId() , (long) status) ;
+ MPTaskID threadid = m_internal->GetId() ;
if ( IsDetached() )
{
wxCriticalSectionLocker lock(m_critsect);
m_internal->SetState(STATE_EXITED);
}
+ MPTerminateTask( threadid , (long) status) ;
}
// also test whether we were paused
{
if ( gs_critsectGui )
{
+ if ( !wxGuiOwnedByMainThread() )
+ {
+ gs_critsectGui->Enter();
+ gs_bGuiOwnedByMainThread = true;
+ }
gs_critsectGui->Leave();
delete gs_critsectGui;
gs_critsectGui = NULL;