2 * \file InGuiThread.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "InGuiThread.h"
15 #include "frontends/Application.h"
19 #include <QApplication>
20 #include <QMutexLocker>
27 IntoGuiThreadMover::IntoGuiThreadMover()
32 void IntoGuiThreadMover::callInGuiThread()
34 if (!theApp() || !QApplication::instance() ||
35 QThread::currentThread() == QApplication::instance()->thread()) {
36 synchronousFunctionCall();
38 moveToThread(QApplication::instance()->thread());
39 connect(this, SIGNAL(triggerFunctionCall()),
40 this, SLOT(doFunctionCall()), Qt::QueuedConnection);
41 QMutexLocker lock(&sync_mutex_);
42 Q_EMIT triggerFunctionCall();
43 condition_.wait(&sync_mutex_);
48 void IntoGuiThreadMover::doFunctionCall()
50 synchronousFunctionCall();
55 } // namespace frontend
58 #include "moc_InGuiThread.cpp"