Drop wxThread::CallEntry() and clean up in platform-specific code
Calling wxThreadSpecificInfo::ThreadCleanUp() in CallEntry() was premature as thread-specific info could be recreated later, e.g. due to any wxLogXXX() call, so don't do it there, but do it in the platform-specific code just before exiting the thread. As this renders CallEntry() useless, remove it entirely.
This commit is contained in:
parent
bda8fc2f14
commit
4d9131d2ec
5 changed files with 16 additions and 20 deletions
|
|
@ -602,9 +602,6 @@ protected:
|
|||
// of this thread.
|
||||
virtual void *Entry() = 0;
|
||||
|
||||
// use this to call the Entry() virtual method
|
||||
void *CallEntry();
|
||||
|
||||
// Callbacks which may be overridden by the derived class to perform some
|
||||
// specific actions when the thread is deleted or killed. By default they
|
||||
// do nothing.
|
||||
|
|
|
|||
|
|
@ -342,16 +342,8 @@ wxSemaError wxSemaphore::Post()
|
|||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/utils.h"
|
||||
#include "wx/private/threadinfo.h"
|
||||
#include "wx/scopeguard.h"
|
||||
|
||||
void wxThread::Sleep(unsigned long milliseconds)
|
||||
{
|
||||
wxMilliSleep(milliseconds);
|
||||
}
|
||||
|
||||
void *wxThread::CallEntry()
|
||||
{
|
||||
wxON_BLOCK_EXIT0(wxThreadSpecificInfo::ThreadCleanUp);
|
||||
return Entry();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ void wxThreadPrivate::SprocStart(void *ptr)
|
|||
|
||||
thr->p_internal->thread_id = getpid();
|
||||
thr->p_internal->exit_status = 0;
|
||||
status = thr->CallEntry();
|
||||
status = thr->Entry();
|
||||
thr->Exit(status);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
#include "wx/apptrait.h"
|
||||
#include "wx/scopeguard.h"
|
||||
|
||||
#include "wx/private/threadinfo.h"
|
||||
|
||||
#include "wx/msw/private.h"
|
||||
#include "wx/msw/missing.h"
|
||||
#include "wx/msw/seh.h"
|
||||
|
|
@ -532,7 +534,7 @@ THREAD_RETVAL wxThreadInternal::DoThreadStart(wxThread *thread)
|
|||
return THREAD_ERROR_EXIT;
|
||||
}
|
||||
|
||||
rc = wxPtrToUInt(thread->CallEntry());
|
||||
rc = wxPtrToUInt(thread->Entry());
|
||||
}
|
||||
wxCATCH_ALL( wxTheApp->OnUnhandledException(); )
|
||||
|
||||
|
|
@ -583,6 +585,10 @@ THREAD_RETVAL THREAD_CALLCONV wxThreadInternal::WinThreadStart(void *param)
|
|||
if ( isDetached )
|
||||
thread->m_internal->LetDie();
|
||||
|
||||
// Do this as the very last thing to ensure that thread-specific info is
|
||||
// not recreated any longer.
|
||||
wxThreadSpecificInfo::ThreadCleanUp();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,9 +27,10 @@
|
|||
|
||||
#include "wx/thread.h"
|
||||
#include "wx/except.h"
|
||||
#include "wx/private/threadinfo.h"
|
||||
#include "wx/scopeguard.h"
|
||||
|
||||
#include "wx/private/threadinfo.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/dynarray.h"
|
||||
|
|
@ -857,6 +858,11 @@ void *wxPthreadStart(void *ptr)
|
|||
|
||||
void *wxThreadInternal::PthreadStart(wxThread *thread)
|
||||
{
|
||||
// Ensure that we clean up thread-specific data before exiting the thread
|
||||
// and do it as late as possible as wxLog calls can recreate it and may
|
||||
// happen until the very end.
|
||||
wxON_BLOCK_EXIT0(wxThreadSpecificInfo::ThreadCleanUp);
|
||||
|
||||
wxThreadInternal *pthread = thread->m_internal;
|
||||
|
||||
wxLogTrace(TRACE_THREADS, wxT("Thread %p started."), THR_ID(pthread));
|
||||
|
|
@ -871,11 +877,6 @@ void *wxThreadInternal::PthreadStart(wxThread *thread)
|
|||
return (void *)-1;
|
||||
}
|
||||
|
||||
// ThreadCleanUp() will be called in thread->CallEntry(),
|
||||
// but there might be wxLog calls after that recreating the thread info.
|
||||
// Make sure they get recleaned when leaving this function.
|
||||
wxON_BLOCK_EXIT0(wxThreadSpecificInfo::ThreadCleanUp);
|
||||
|
||||
// have to declare this before pthread_cleanup_push() which defines a
|
||||
// block!
|
||||
bool dontRunAtAll;
|
||||
|
|
@ -907,7 +908,7 @@ void *wxThreadInternal::PthreadStart(wxThread *thread)
|
|||
|
||||
wxTRY
|
||||
{
|
||||
pthread->m_exitcode = thread->CallEntry();
|
||||
pthread->m_exitcode = thread->Entry();
|
||||
|
||||
wxLogTrace(TRACE_THREADS,
|
||||
wxT("Thread %p Entry() returned %lu."),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue