mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-18 05:37:11 +00:00
check also if there is a QApplication instance
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35981 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a3c84666b2
commit
8718c455a6
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include "InGuiThread.h"
|
#include "InGuiThread.h"
|
||||||
|
|
||||||
|
#include "frontends/Application.h"
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@ -29,11 +31,11 @@ IntoGuiThreadMover::IntoGuiThreadMover()
|
|||||||
|
|
||||||
void IntoGuiThreadMover::callInGuiThread()
|
void IntoGuiThreadMover::callInGuiThread()
|
||||||
{
|
{
|
||||||
QThread* gui_thread = QApplication::instance()->thread();
|
if (!theApp() || !QApplication::instance() ||
|
||||||
if (QThread::currentThread() == gui_thread) {
|
QThread::currentThread() == QApplication::instance()->thread()) {
|
||||||
synchronousFunctionCall();
|
synchronousFunctionCall();
|
||||||
} else {
|
} else {
|
||||||
moveToThread(gui_thread);
|
moveToThread(QApplication::instance()->thread());
|
||||||
connect(this, SIGNAL(triggerFunctionCall()),
|
connect(this, SIGNAL(triggerFunctionCall()),
|
||||||
this, SLOT(doFunctionCall()), Qt::QueuedConnection);
|
this, SLOT(doFunctionCall()), Qt::QueuedConnection);
|
||||||
QMutexLocker lock(&sync_mutex_);
|
QMutexLocker lock(&sync_mutex_);
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QWaitCondition>
|
#include <QWaitCondition>
|
||||||
|
|
||||||
#include "frontends/Application.h"
|
|
||||||
#include "support/bind.h"
|
#include "support/bind.h"
|
||||||
#include "support/functional.h"
|
#include "support/functional.h"
|
||||||
|
|
||||||
@ -59,10 +58,7 @@ public:
|
|||||||
R call(F f)
|
R call(F f)
|
||||||
{
|
{
|
||||||
func_ = f;
|
func_ = f;
|
||||||
if (theApp() == 0)
|
callInGuiThread();
|
||||||
synchronousFunctionCall();
|
|
||||||
else
|
|
||||||
callInGuiThread();
|
|
||||||
return return_value_;
|
return return_value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,10 +121,7 @@ public:
|
|||||||
void call(F f)
|
void call(F f)
|
||||||
{
|
{
|
||||||
func_ = f;
|
func_ = f;
|
||||||
if (theApp() == 0)
|
callInGuiThread();
|
||||||
synchronousFunctionCall();
|
|
||||||
else
|
|
||||||
callInGuiThread();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class F, class P1>
|
template<class F, class P1>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user