Skip to content

Commit

Permalink
Changed wait() to non-blocking sleep for waiting that thread exits in…
Browse files Browse the repository at this point in the history
… 'EngineShoutcast::~EngineShoutcast()'
  • Loading branch information
illuusio committed Oct 30, 2015
1 parent 94957bb commit 4743a48
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/engine/sidechain/engineshoutcast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,26 @@ EngineShoutcast::EngineShoutcast(ConfigObject<ConfigValue>* _config)
}

EngineShoutcast::~EngineShoutcast() {
int l_iTime = 0;
m_pShoutcastEnabled->set(0);
m_readSema.release();
wait(); // until the thread ends.

// Because Thread QThread msec doesn't blocking
// If we can believe this:
// http://stackoverflow.com/questions/1950160/what-can-i-use-to-replace-sleep-and-usleep-in-my-qt-app
while(l_iTime < 100) {
// If Thread has exited then just break out
if(!isRunning()) {
break;
}
l_iTime ++;
QThread::msleep(100);
}

// Signal user if thread doesn't die
if(isRunning()) {
qDebug() << "EngineShoutcast::~EngineShoutcast(): Thread didn't die. Ignored but add this to bug report if problems rise!";
}

delete m_pStatusCO;
delete m_pMasterSamplerate;
Expand Down

0 comments on commit 4743a48

Please sign in to comment.