From b671089c6675c07bc9e166ca5a83976b2277e4c4 Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Sat, 7 May 2016 14:21:11 +0200 Subject: [PATCH] Finish workaround for xbus causing X-Plane infinite loop on Mac OS X In the first commit of this workaround, not all QApplications were replaced by QCoreApplications. For unknown reasons, the single replacement solved the problem. With Qt 5.6 it appeared again. This commit finishes now the workaround. refs #293 --- src/xbus/utils.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/xbus/utils.h b/src/xbus/utils.h index 2a213dc97..7b38d4e2f 100644 --- a/src/xbus/utils.h +++ b/src/xbus/utils.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -82,13 +82,13 @@ public: * Qt framework, they can simply copy & paste this class into their project * and both X-Plane plugins will be able to share a single QApplication safely. */ -class QSharedApplication : public QApplication +class QSharedApplication : public QCoreApplication { Q_OBJECT - QWeakPointer m_weakptr; + QWeakPointer m_weakptr; - QSharedApplication(QSharedPointer &ptr, int &argc, char **argv) : QApplication(argc, argv) + QSharedApplication(QSharedPointer &ptr, int &argc, char **argv) : QCoreApplication(argc, argv) { ptr.reset(this); m_weakptr = ptr; @@ -102,9 +102,9 @@ public: * * The QApplication will not be destroyed while this shared pointer exists. */ - static QSharedPointer sharedInstance() + static QSharedPointer sharedInstance() { - QSharedPointer ptr; + QSharedPointer ptr; if (! instance()) { static int argc = 1; @@ -123,7 +123,7 @@ public: } if (! instance()->inherits("QSharedApplication")) { - qFatal("There is an unshared QApplication in another plugin"); + qFatal("There is an unshared QCoreApplication in another plugin"); } return static_cast(instance())->m_weakptr; } @@ -148,8 +148,8 @@ class QXPlaneEventLoop : public QObject static float callback(float, float, int, void *) { - QApplication::processEvents(); - QApplication::sendPostedEvents(); + QCoreApplication::processEvents(); + QCoreApplication::sendPostedEvents(); return -1; } @@ -160,9 +160,9 @@ public: */ static void exec() { - if (! QApplication::instance()->findChild()) + if (! QCoreApplication::instance()->findChild()) { - new QXPlaneEventLoop(QApplication::instance()); + new QXPlaneEventLoop(QCoreApplication::instance()); } } };