#include "InGuiThread.h"
+#include "frontends/Application.h"
+
#include <QThread>
#include <QEventLoop>
#include <QApplication>
void IntoGuiThreadMover::callInGuiThread()
{
- QThread* gui_thread = QApplication::instance()->thread();
- if (QThread::currentThread() == gui_thread) {
+ if (!theApp() || !QApplication::instance() ||
+ QThread::currentThread() == QApplication::instance()->thread()) {
synchronousFunctionCall();
} else {
- moveToThread(gui_thread);
+ moveToThread(QApplication::instance()->thread());
connect(this, SIGNAL(triggerFunctionCall()),
this, SLOT(doFunctionCall()), Qt::QueuedConnection);
QMutexLocker lock(&sync_mutex_);
#include <QObject>
#include <QWaitCondition>
-#include "frontends/Application.h"
#include "support/bind.h"
#include "support/functional.h"
R call(F f)
{
func_ = f;
- if (theApp() == 0)
- synchronousFunctionCall();
- else
- callInGuiThread();
+ callInGuiThread();
return return_value_;
}
void call(F f)
{
func_ = f;
- if (theApp() == 0)
- synchronousFunctionCall();
- else
- callInGuiThread();
+ callInGuiThread();
}
template<class F, class P1>