refs #605, make sure the main thread is not terminated

In unit test a reader was to started. Here it was happening the main thread was terminated accidentally
This commit is contained in:
Klaus Basan
2016-02-27 22:20:35 +01:00
committed by Mathew Sutcliffe
parent f1ace9dde0
commit f03f3ef224

View File

@@ -8,6 +8,7 @@
*/
#include "worker.h"
#include "blackmisc/threadutils.h"
#include <future>
namespace BlackMisc
@@ -91,11 +92,13 @@ namespace BlackMisc
void CContinuousWorker::quit() Q_DECL_NOEXCEPT
{
Q_ASSERT_X(!CThreadUtils::isApplicationThreadObjectThread(this), Q_FUNC_INFO, "Try to stop main thread");
thread()->quit();
}
void CContinuousWorker::quitAndWait() Q_DECL_NOEXCEPT
{
Q_ASSERT_X(!CThreadUtils::isApplicationThreadObjectThread(this), Q_FUNC_INFO, "Try to stop main thread");
auto *ownThread = thread();
quit();
ownThread->wait();