From 9cfeaf4c0ad47ab3b127550490c3d8971babbb80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=BCmmel?= Date: Thu, 21 Oct 2010 08:02:09 +0000 Subject: [PATCH] only connect when needed git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35743 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/InGuiThread.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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();