]> git.lyx.org Git - features.git/commitdiff
only connect when needed
authorPeter Kümmel <syntheticpp@gmx.net>
Thu, 21 Oct 2010 08:02:09 +0000 (08:02 +0000)
committerPeter Kümmel <syntheticpp@gmx.net>
Thu, 21 Oct 2010 08:02:09 +0000 (08:02 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35743 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/InGuiThread.cpp

index bd47e50e4b6e7c2ddc65f45e9fd4a8f961517fdf..b9332997f196951047039d0cd2d97ac1fd7e1921 100644 (file)
@@ -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();