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"
17 #include <QApplication>
18 #include <QMutexLocker>
25 IntoGuiThreadMover::IntoGuiThreadMover()
30 void IntoGuiThreadMover::callInGuiThread()
32 QThread* gui_thread = QApplication::instance()->thread();
33 if (QThread::currentThread() == gui_thread) {
34 synchronousFunctionCall();
36 moveToThread(gui_thread);
37 connect(this, SIGNAL(triggerFunctionCall()),
38 this, SLOT(doFunctionCall()), Qt::QueuedConnection);
39 QMutexLocker lock(&sync_mutex_);
40 Q_EMIT triggerFunctionCall();
41 condition_.wait(&sync_mutex_);
46 void IntoGuiThreadMover::doFunctionCall()
48 synchronousFunctionCall();
53 } // namespace frontend
56 #include "moc_InGuiThread.cpp"