]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/InGuiThread.cpp
Use <cstdint> instead of <boost/cstdint.hpp>
[lyx.git] / src / frontends / qt4 / InGuiThread.cpp
index ff53f9d0e9619be2564ea3b2f890b314e44df351..faaf806a07396c6dbe6456fb9f754abd205894b5 100644 (file)
@@ -12,6 +12,8 @@
 
 #include "InGuiThread.h"
 
+#include "frontends/Application.h"
+
 #include <QThread>
 #include <QEventLoop>
 #include <QApplication>
@@ -29,12 +31,12 @@ IntoGuiThreadMover::IntoGuiThreadMover()
 
 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);
-               connect(this, SIGNAL(triggerFunctionCall()), 
+               moveToThread(QApplication::instance()->thread());
+               connect(this, SIGNAL(triggerFunctionCall()),
                        this, SLOT(doFunctionCall()), Qt::QueuedConnection);
                QMutexLocker lock(&sync_mutex_);
                Q_EMIT triggerFunctionCall();