mirror-chatterino2/lib/appbase/debug/AssertInGuiThread.hpp

22 lines
352 B
C++
Raw Normal View History

#pragma once
#include <QCoreApplication>
#include <QThread>
#include <cassert>
namespace AB_NAMESPACE {
2019-08-01 13:30:58 +02:00
static bool isGuiThread()
{
return QCoreApplication::instance()->thread() == QThread::currentThread();
}
static void assertInGuiThread()
{
#ifdef _DEBUG
2019-08-01 13:30:58 +02:00
assert(isGuiThread());
#endif
}
} // namespace AB_NAMESPACE