UI: Add WaitConnection() helper func

A helper function used with QMetaObject::invokeMethod which allows the
ability to use Qt::DirectConnection if on the Qt UI thread, or
Qt::BlockingQueuedConnection if on another thread to ensure that
regardless of what thread the invokeMethod is called from, that it will
wait until the invoked method has been called.
This commit is contained in:
jp9000 2018-05-04 15:30:40 -07:00
parent 2d9691fc23
commit e7f2cc384d

View File

@ -17,8 +17,10 @@
#pragma once
#include <QApplication>
#include <QMessageBox>
#include <QWidget>
#include <QThread>
#include <obs.hpp>
#include <memory>
@ -79,3 +81,10 @@ public:
};
void DeleteLayout(QLayout *layout);
static inline Qt::ConnectionType WaitConnection()
{
return QThread::currentThread() == qApp->thread()
? Qt::DirectConnection
: Qt::BlockingQueuedConnection;
}