From: Peter Kümmel Date: Thu, 21 Oct 2010 08:02:09 +0000 (+0000) Subject: only connect when needed X-Git-Tag: 2.0.0~2320 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=9cfeaf4c0ad47ab3b127550490c3d8971babbb80;p=features.git only connect when needed git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35743 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/InGuiThread.cpp b/src/frontends/qt4/InGuiThread.cpp index bd47e50e4b..b9332997f1 100644 --- a/src/frontends/qt4/InGuiThread.cpp +++ b/src/frontends/qt4/InGuiThread.cpp @@ -22,17 +22,19 @@ namespace frontend { IntoGuiThreadMover::IntoGuiThreadMover() { - moveToThread(QApplication::instance()->thread()); - connect(this, SIGNAL(triggerCall()), this, SLOT(doFunctionCall()), - Qt::QueuedConnection); } void IntoGuiThreadMover::callInGuiThread() { - if (QThread::currentThread() == QApplication::instance()->thread()) { + QThread* gui_thread = QApplication::instance()->thread(); + if (QThread::currentThread() == gui_thread) { synchronousFunctionCall(); } else { + moveToThread(gui_thread); + connect(this, SIGNAL(triggerCall()), this, SLOT(doFunctionCall()), + Qt::QueuedConnection); + // TODO try with condition, it's maybe cheaper QEventLoop loop; connect(this, SIGNAL(called()), &loop, SLOT(quit())); Q_EMIT triggerCall();