Permalink
Browse files

make sure not to delete a CThread object while spawn thread is in pro…

…cess
  • Loading branch information...
FernetMenta committed May 9, 2018
1 parent 4e05287 commit e4f4797549bb8baf26cc9bf2644c5be89b9b1c66
Showing with 4 additions and 2 deletions.
  1. +4 −2 xbmc/threads/Thread.cpp
View
@@ -39,7 +39,7 @@ static thread_local CThread* currentThread;
//////////////////////////////////////////////////////////////////////
CThread::CThread(const char* ThreadName)
-: m_StopEvent(true,true), m_TermEvent(true), m_StartEvent(true)
+: m_StopEvent(true,true), m_TermEvent(true), m_StartEvent(true, true)
{
m_bStop = false;
@@ -56,7 +56,7 @@ CThread::CThread(const char* ThreadName)
}
CThread::CThread(IRunnable* pRunnable, const char* ThreadName)
-: m_StopEvent(true,true), m_TermEvent(true), m_StartEvent(true)
+: m_StopEvent(true, true), m_TermEvent(true), m_StartEvent(true, true)
{
m_bStop = false;
@@ -154,6 +154,8 @@ bool CThread::IsAutoDelete() const
void CThread::StopThread(bool bWait /*= true*/)
{
+ m_StartEvent.Wait();
+
m_bStop = true;
m_StopEvent.Set();
CSingleLock lock(m_CriticalSection);

0 comments on commit e4f4797

Please sign in to comment.