From 8718c455a65c947237833557922e5626979e56da Mon Sep 17 00:00:00 2001 From: =?utf8?q?Peter=20K=C3=BCmmel?= Date: Mon, 1 Nov 2010 21:32:59 +0000 Subject: [PATCH] check also if there is a QApplication instance git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35981 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/InGuiThread.cpp | 8 +++++--- src/frontends/qt4/InGuiThread.h | 11 ++--------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/frontends/qt4/InGuiThread.cpp b/src/frontends/qt4/InGuiThread.cpp index ff53f9d0e9..20be94cffe 100644 --- a/src/frontends/qt4/InGuiThread.cpp +++ b/src/frontends/qt4/InGuiThread.cpp @@ -12,6 +12,8 @@ #include "InGuiThread.h" +#include "frontends/Application.h" + #include #include #include @@ -29,11 +31,11 @@ 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); + moveToThread(QApplication::instance()->thread()); connect(this, SIGNAL(triggerFunctionCall()), this, SLOT(doFunctionCall()), Qt::QueuedConnection); QMutexLocker lock(&sync_mutex_); diff --git a/src/frontends/qt4/InGuiThread.h b/src/frontends/qt4/InGuiThread.h index f27317f4c8..4939c64726 100644 --- a/src/frontends/qt4/InGuiThread.h +++ b/src/frontends/qt4/InGuiThread.h @@ -16,7 +16,6 @@ #include #include -#include "frontends/Application.h" #include "support/bind.h" #include "support/functional.h" @@ -59,10 +58,7 @@ public: R call(F f) { func_ = f; - if (theApp() == 0) - synchronousFunctionCall(); - else - callInGuiThread(); + callInGuiThread(); return return_value_; } @@ -125,10 +121,7 @@ public: void call(F f) { func_ = f; - if (theApp() == 0) - synchronousFunctionCall(); - else - callInGuiThread(); + callInGuiThread(); } template -- 2.39.2