only connect when needed

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35743 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Peter Kümmel 2010-10-21 08:02:09 +00:00
parent cf570e0a8d
commit 9cfeaf4c0a

View 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();