From 999e5162ec3e86c9cb84c3ec95dfd0ba4b21277f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 26 Sep 2013 12:14:32 +0200 Subject: QPA: Fix semantics of GUI event dispatcher ownership in platform plugins The QPlatformIntegration::guiThreadEventDispatcher() function acted as an accessor to event dispatchers created in the constructor of each platform plugin, but the logic and semantics of event-dispatcher handling in Qt itself (QCoreApplication/QGuiApplication) still assumed both ownership and control over the event dispatcher, such as when to create one, which one to create, and when to delete it. This conflicted with the explicit calls in the platform plugins to QGuiApplication::setEventDispatcher(), as well as left a possibility that the event-dispatcher created by the platform plugin would never be deleted, as none of the platform plugins actually took full ownership of the dispatcher and deleted it in its destructor. The integration function has now been renamed back to its old name, createEventDispatcher(), and acts as a factory function, leaving the logic and lifetime of event dispatcher to QtCoreApplication. The only platform left with creating the event-dispatcher in the constructor is QNX, where other parts of the platform relies on having an event-dispatcher before their initialization. We then need to manually take care of the ownership transfer, so that the event-dispatcher is still destroyed at some point. Change-Id: I113db97d2545ebda39ebdefa865e488d2ce9368b Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- .../android/src/qandroidplatformintegration.cpp | 8 ++------ .../platforms/android/src/qandroidplatformintegration.h | 3 +-- src/plugins/platforms/cocoa/qcocoaintegration.h | 3 +-- src/plugins/platforms/cocoa/qcocoaintegration.mm | 5 ++--- src/plugins/platforms/directfb/qdirectfbintegration.cpp | 6 ++---- src/plugins/platforms/directfb/qdirectfbintegration.h | 3 +-- src/plugins/platforms/eglfs/qeglfsintegration.cpp | 11 ++++------- src/plugins/platforms/eglfs/qeglfsintegration.h | 3 +-- src/plugins/platforms/ios/qiosintegration.h | 2 +- src/plugins/platforms/ios/qiosintegration.mm | 2 +- src/plugins/platforms/kms/qkmsintegration.cpp | 6 ++---- src/plugins/platforms/kms/qkmsintegration.h | 3 +-- src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp | 9 +++------ src/plugins/platforms/linuxfb/qlinuxfbintegration.h | 3 +-- src/plugins/platforms/minimal/qminimalintegration.cpp | 16 +++++++--------- src/plugins/platforms/minimal/qminimalintegration.h | 5 +---- .../platforms/minimalegl/qminimaleglintegration.cpp | 2 +- .../platforms/minimalegl/qminimaleglintegration.h | 2 +- .../platforms/offscreen/qoffscreenintegration.cpp | 13 ++++++++----- src/plugins/platforms/offscreen/qoffscreenintegration.h | 3 +-- src/plugins/platforms/openwfd/qopenwfdintegration.cpp | 6 ++---- src/plugins/platforms/openwfd/qopenwfdintegration.h | 3 +-- src/plugins/platforms/qnx/qqnxintegration.cpp | 12 ++++++++++-- src/plugins/platforms/qnx/qqnxintegration.h | 4 ++-- src/plugins/platforms/windows/qwindowsintegration.cpp | 7 ++----- src/plugins/platforms/windows/qwindowsintegration.h | 2 +- src/plugins/platforms/xcb/qxcbintegration.cpp | 9 +++------ src/plugins/platforms/xcb/qxcbintegration.h | 3 +-- 28 files changed, 64 insertions(+), 90 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp index 358c3caf89..9ce382bd53 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp @@ -100,10 +100,6 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ { Q_UNUSED(paramList); -#ifndef ANDROID_PLUGIN_OPENGL - m_eventDispatcher = createUnixEventDispatcher(); -#endif - m_androidPlatformNativeInterface = new QAndroidPlatformNativeInterface(); #ifndef ANDROID_PLUGIN_OPENGL @@ -150,9 +146,9 @@ QPlatformWindow *QAndroidPlatformIntegration::createPlatformWindow(QWindow *wind return new QAndroidPlatformWindow(window); } -QAbstractEventDispatcher *QAndroidPlatformIntegration::guiThreadEventDispatcher() const +QAbstractEventDispatcher *QAndroidPlatformIntegration::createEventDispatcher() const { - return m_eventDispatcher; + return createUnixEventDispatcher(); } #else // !ANDROID_PLUGIN_OPENGL QPlatformWindow *QAndroidPlatformIntegration::createPlatformWindow(QWindow *window) const diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.h b/src/plugins/platforms/android/src/qandroidplatformintegration.h index e7bb55b3d5..5ebdf9e65c 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.h @@ -93,7 +93,7 @@ public: #ifndef ANDROID_PLUGIN_OPENGL QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; QPlatformWindow *createPlatformWindow(QWindow *window) const; - QAbstractEventDispatcher *guiThreadEventDispatcher() const; + QAbstractEventDispatcher *createEventDispatcher() const; QAndroidPlatformScreen *screen() { return m_primaryScreen; } #else QPlatformWindow *createPlatformWindow(QWindow *window) const; @@ -147,7 +147,6 @@ private: QTouchDevice *m_touchDevice; #ifndef ANDROID_PLUGIN_OPENGL - QAbstractEventDispatcher *m_eventDispatcher; QAndroidPlatformScreen *m_primaryScreen; #endif diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index 8620ef4267..111329aaee 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -108,7 +108,7 @@ public: QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const; QPlatformBackingStore *createPlatformBackingStore(QWindow *widget) const; - QAbstractEventDispatcher *guiThreadEventDispatcher() const; + QAbstractEventDispatcher *createEventDispatcher() const; QPlatformFontDatabase *fontDatabase() const; QPlatformNativeInterface *nativeInterface() const; @@ -130,7 +130,6 @@ public: private: QScopedPointer mFontDb; - QAbstractEventDispatcher *mEventDispatcher; QScopedPointer mInputContext; #ifndef QT_NO_ACCESSIBILITY diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 365fa92470..8ce72e08b5 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -216,7 +216,6 @@ QPixmap QCocoaScreen::grabWindow(WId window, int x, int y, int width, int height QCocoaIntegration::QCocoaIntegration() : mFontDb(new QCoreTextFontDatabase()) - , mEventDispatcher(new QCocoaEventDispatcher()) , mInputContext(new QCocoaInputContext) #ifndef QT_NO_ACCESSIBILITY , mAccessibility(new QCocoaAccessibility) @@ -384,9 +383,9 @@ QPlatformBackingStore *QCocoaIntegration::createPlatformBackingStore(QWindow *wi return new QCocoaBackingStore(window); } -QAbstractEventDispatcher *QCocoaIntegration::guiThreadEventDispatcher() const +QAbstractEventDispatcher *QCocoaIntegration::createEventDispatcher() const { - return mEventDispatcher; + return new QCocoaEventDispatcher; } QPlatformFontDatabase *QCocoaIntegration::fontDatabase() const diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.cpp b/src/plugins/platforms/directfb/qdirectfbintegration.cpp index 9e8120a29e..7ca7da8bcd 100644 --- a/src/plugins/platforms/directfb/qdirectfbintegration.cpp +++ b/src/plugins/platforms/directfb/qdirectfbintegration.cpp @@ -61,9 +61,7 @@ QT_BEGIN_NAMESPACE QDirectFbIntegration::QDirectFbIntegration() : m_fontDb(new QGenericUnixFontDatabase()) - , m_eventDispatcher(createUnixEventDispatcher()) { - QGuiApplicationPrivate::instance()->setEventDispatcher(m_eventDispatcher); } void QDirectFbIntegration::initialize() @@ -129,9 +127,9 @@ QPlatformWindow *QDirectFbIntegration::createPlatformWindow(QWindow *window) con return dfbWindow; } -QAbstractEventDispatcher *QDirectFbIntegration::guiThreadEventDispatcher() const +QAbstractEventDispatcher *QDirectFbIntegration::createEventDispatcher() const { - return m_eventDispatcher; + return createUnixEventDispatcher(); } QPlatformBackingStore *QDirectFbIntegration::createPlatformBackingStore(QWindow *window) const diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.h b/src/plugins/platforms/directfb/qdirectfbintegration.h index b96e6d96de..5822202eea 100644 --- a/src/plugins/platforms/directfb/qdirectfbintegration.h +++ b/src/plugins/platforms/directfb/qdirectfbintegration.h @@ -65,7 +65,7 @@ public: QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const; QPlatformWindow *createPlatformWindow(QWindow *window) const; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; - QAbstractEventDispatcher *guiThreadEventDispatcher() const; + QAbstractEventDispatcher *createEventDispatcher() const; QPlatformFontDatabase *fontDatabase() const; @@ -80,7 +80,6 @@ protected: QScopedPointer m_input; QScopedPointer m_inputRunner; QScopedPointer m_fontDb; - QAbstractEventDispatcher *m_eventDispatcher; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index ff06ac223b..a6d964dcb0 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -78,12 +78,9 @@ QT_BEGIN_NAMESPACE static void *eglContextForContext(QOpenGLContext *context); QEglFSIntegration::QEglFSIntegration() - : mEventDispatcher(createUnixEventDispatcher()), - mFontDb(new QGenericUnixFontDatabase), - mServices(new QGenericUnixServices) + : mFontDb(new QGenericUnixFontDatabase) + , mServices(new QGenericUnixServices) { - QGuiApplicationPrivate::instance()->setEventDispatcher(mEventDispatcher); - #if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK)) new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString() /* spec */, this); new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString() /* spec */, this); @@ -168,9 +165,9 @@ QPlatformFontDatabase *QEglFSIntegration::fontDatabase() const return mFontDb.data(); } -QAbstractEventDispatcher *QEglFSIntegration::guiThreadEventDispatcher() const +QAbstractEventDispatcher *QEglFSIntegration::createEventDispatcher() const { - return mEventDispatcher; + return createUnixEventDispatcher(); } QVariant QEglFSIntegration::styleHint(QPlatformIntegration::StyleHint hint) const diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.h b/src/plugins/platforms/eglfs/qeglfsintegration.h index c6265bb970..4e24e2f2f7 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.h +++ b/src/plugins/platforms/eglfs/qeglfsintegration.h @@ -67,7 +67,7 @@ public: QPlatformFontDatabase *fontDatabase() const; QPlatformServices *services() const; - QAbstractEventDispatcher *guiThreadEventDispatcher() const; + QAbstractEventDispatcher *createEventDispatcher() const; QVariant styleHint(QPlatformIntegration::StyleHint hint) const; @@ -87,7 +87,6 @@ public: private: EGLDisplay mDisplay; - QAbstractEventDispatcher *mEventDispatcher; QScopedPointer mFontDb; QScopedPointer mServices; QEglFSScreen *mScreen; diff --git a/src/plugins/platforms/ios/qiosintegration.h b/src/plugins/platforms/ios/qiosintegration.h index 4aaf98f839..a75696625e 100644 --- a/src/plugins/platforms/ios/qiosintegration.h +++ b/src/plugins/platforms/ios/qiosintegration.h @@ -70,7 +70,7 @@ public: QStringList themeNames() const; QPlatformTheme *createPlatformTheme(const QString &name) const; - QAbstractEventDispatcher *guiThreadEventDispatcher() const; + QAbstractEventDispatcher *createEventDispatcher() const; QPlatformNativeInterface *nativeInterface() const; void *nativeResourceForWindow(const QByteArray &resource, QWindow *window); diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm index d854bf7723..862e3b4a10 100644 --- a/src/plugins/platforms/ios/qiosintegration.mm +++ b/src/plugins/platforms/ios/qiosintegration.mm @@ -113,7 +113,7 @@ QPlatformOpenGLContext *QIOSIntegration::createPlatformOpenGLContext(QOpenGLCont return new QIOSContext(context); } -QAbstractEventDispatcher *QIOSIntegration::guiThreadEventDispatcher() const +QAbstractEventDispatcher *QIOSIntegration::createEventDispatcher() const { if (isQtApplication()) return new QIOSEventDispatcher; diff --git a/src/plugins/platforms/kms/qkmsintegration.cpp b/src/plugins/platforms/kms/qkmsintegration.cpp index 539363722d..80c5887a28 100644 --- a/src/plugins/platforms/kms/qkmsintegration.cpp +++ b/src/plugins/platforms/kms/qkmsintegration.cpp @@ -65,10 +65,8 @@ QT_BEGIN_NAMESPACE QKmsIntegration::QKmsIntegration() : QPlatformIntegration(), m_fontDatabase(new QGenericUnixFontDatabase()), - m_eventDispatcher(createUnixEventDispatcher()), m_nativeInterface(new QKmsNativeInterface) { - QGuiApplicationPrivate::instance()->setEventDispatcher(m_eventDispatcher); setenv("EGL_PLATFORM", "drm",1); m_vtHandler = new QKmsVTHandler; @@ -152,9 +150,9 @@ void QKmsIntegration::addScreen(QKmsScreen *screen) screenAdded(screen); } -QAbstractEventDispatcher *QKmsIntegration::guiThreadEventDispatcher() const +QAbstractEventDispatcher *QKmsIntegration::createEventDispatcher() const { - return m_eventDispatcher; + return createUnixEventDispatcher(); } QPlatformNativeInterface *QKmsIntegration::nativeInterface() const diff --git a/src/plugins/platforms/kms/qkmsintegration.h b/src/plugins/platforms/kms/qkmsintegration.h index 5069753aa5..0a626e6bd2 100644 --- a/src/plugins/platforms/kms/qkmsintegration.h +++ b/src/plugins/platforms/kms/qkmsintegration.h @@ -67,7 +67,7 @@ public: QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; QPlatformFontDatabase *fontDatabase() const; - QAbstractEventDispatcher *guiThreadEventDispatcher() const; + QAbstractEventDispatcher *createEventDispatcher() const; QPlatformNativeInterface *nativeInterface() const; @@ -84,7 +84,6 @@ private: QList m_screens; QList m_devices; QPlatformFontDatabase *m_fontDatabase; - QAbstractEventDispatcher *m_eventDispatcher; QPlatformNativeInterface *m_nativeInterface; QKmsVTHandler *m_vtHandler; QDeviceDiscovery *m_deviceDiscovery; diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp index 99914fa36d..aa2687da30 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp @@ -54,11 +54,8 @@ QT_BEGIN_NAMESPACE QLinuxFbIntegration::QLinuxFbIntegration(const QStringList ¶mList) - : m_fontDb(new QGenericUnixFontDatabase()), - m_eventDispatcher(createUnixEventDispatcher()) + : m_fontDb(new QGenericUnixFontDatabase()) { - QGuiApplicationPrivate::instance()->setEventDispatcher(m_eventDispatcher); - m_primaryScreen = new QLinuxFbScreen; if (m_primaryScreen->initialize(paramList)) screenAdded(m_primaryScreen); @@ -92,9 +89,9 @@ QPlatformWindow *QLinuxFbIntegration::createPlatformWindow(QWindow *window) cons return new QFbWindow(window); } -QAbstractEventDispatcher *QLinuxFbIntegration::guiThreadEventDispatcher() const +QAbstractEventDispatcher *QLinuxFbIntegration::createEventDispatcher() const { - return m_eventDispatcher; + return createUnixEventDispatcher(); } QList QLinuxFbIntegration::screens() const diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h index 1d91d364ff..6de9ac9992 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h @@ -61,14 +61,13 @@ public: QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const; QPlatformWindow *createPlatformWindow(QWindow *window) const; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; - QAbstractEventDispatcher *guiThreadEventDispatcher() const; + QAbstractEventDispatcher *createEventDispatcher() const; QList screens() const; QPlatformFontDatabase *fontDatabase() const; private: QLinuxFbScreen *m_primaryScreen; QPlatformFontDatabase *m_fontDb; - QAbstractEventDispatcher *m_eventDispatcher; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp index 8d0586a5a3..a08cede76a 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.cpp +++ b/src/plugins/platforms/minimal/qminimalintegration.cpp @@ -53,14 +53,8 @@ QT_BEGIN_NAMESPACE -QMinimalIntegration::QMinimalIntegration() : -#ifdef Q_OS_WIN - m_eventDispatcher(new QEventDispatcherWin32()) -#else - m_eventDispatcher(createUnixEventDispatcher()) -#endif +QMinimalIntegration::QMinimalIntegration() { - QGuiApplicationPrivate::instance()->setEventDispatcher(m_eventDispatcher); QMinimalScreen *mPrimaryScreen = new QMinimalScreen(); mPrimaryScreen->mGeometry = QRect(0, 0, 240, 320); @@ -92,9 +86,13 @@ QPlatformBackingStore *QMinimalIntegration::createPlatformBackingStore(QWindow * return new QMinimalBackingStore(window); } -QAbstractEventDispatcher *QMinimalIntegration::guiThreadEventDispatcher() const +QAbstractEventDispatcher *QMinimalIntegration::createEventDispatcher() const { - return m_eventDispatcher; +#ifdef Q_OS_WIN + return new QEventDispatcherWin32; +#else + return createUnixEventDispatcher(); +#endif } QT_END_NAMESPACE diff --git a/src/plugins/platforms/minimal/qminimalintegration.h b/src/plugins/platforms/minimal/qminimalintegration.h index ef39e32fa7..7dc01e1d51 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.h +++ b/src/plugins/platforms/minimal/qminimalintegration.h @@ -73,10 +73,7 @@ public: QPlatformWindow *createPlatformWindow(QWindow *window) const; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; - QAbstractEventDispatcher *guiThreadEventDispatcher() const; - -private: - QAbstractEventDispatcher *m_eventDispatcher; + QAbstractEventDispatcher *createEventDispatcher() const; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp b/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp index 4a1ac0f307..21c23250e4 100644 --- a/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp +++ b/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp @@ -110,7 +110,7 @@ QPlatformFontDatabase *QMinimalEglIntegration::fontDatabase() const return mFontDb; } -QAbstractEventDispatcher *QMinimalEglIntegration::guiThreadEventDispatcher() const +QAbstractEventDispatcher *QMinimalEglIntegration::createEventDispatcher() const { return createUnixEventDispatcher(); } diff --git a/src/plugins/platforms/minimalegl/qminimaleglintegration.h b/src/plugins/platforms/minimalegl/qminimaleglintegration.h index dba7504033..58b8f28ac9 100644 --- a/src/plugins/platforms/minimalegl/qminimaleglintegration.h +++ b/src/plugins/platforms/minimalegl/qminimaleglintegration.h @@ -63,7 +63,7 @@ public: QPlatformFontDatabase *fontDatabase() const; - QAbstractEventDispatcher *guiThreadEventDispatcher() const; + QAbstractEventDispatcher *createEventDispatcher() const; QVariant styleHint(QPlatformIntegration::StyleHint hint) const; diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp index bce52963df..a1da8e3a16 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp @@ -95,14 +95,12 @@ public: QOffscreenIntegration::QOffscreenIntegration() { #if defined(Q_OS_UNIX) - m_eventDispatcher = createUnixEventDispatcher(); #if defined(Q_OS_MAC) m_fontDatabase.reset(new QPlatformFontDatabase()); #else m_fontDatabase.reset(new QGenericUnixFontDatabase()); #endif #elif defined(Q_OS_WIN) - m_eventDispatcher = new QOffscreenEventDispatcher(); m_fontDatabase.reset(new QBasicFontDatabase()); #endif @@ -111,7 +109,6 @@ QOffscreenIntegration::QOffscreenIntegration() #endif m_services.reset(new QPlatformServices); - QGuiApplicationPrivate::instance()->setEventDispatcher(m_eventDispatcher); screenAdded(new QOffscreenScreen); } @@ -141,9 +138,15 @@ QPlatformBackingStore *QOffscreenIntegration::createPlatformBackingStore(QWindow return new QOffscreenBackingStore(window); } -QAbstractEventDispatcher *QOffscreenIntegration::guiThreadEventDispatcher() const +QAbstractEventDispatcher *QOffscreenIntegration::createEventDispatcher() const { - return m_eventDispatcher; +#if defined(Q_OS_UNIX) + return createUnixEventDispatcher(); +#elif defined(Q_OS_WIN) + return new QOffscreenEventDispatcher(); +#else + return 0; +#endif } QPlatformFontDatabase *QOffscreenIntegration::fontDatabase() const diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.h b/src/plugins/platforms/offscreen/qoffscreenintegration.h index b403ce83b3..c7cdb5fdd6 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration.h +++ b/src/plugins/platforms/offscreen/qoffscreenintegration.h @@ -66,12 +66,11 @@ public: QPlatformServices *services() const; QPlatformFontDatabase *fontDatabase() const; - QAbstractEventDispatcher *guiThreadEventDispatcher() const; + QAbstractEventDispatcher *createEventDispatcher() const; static QOffscreenIntegration *createOffscreenIntegration(); private: - QAbstractEventDispatcher *m_eventDispatcher; QScopedPointer m_fontDatabase; #ifndef QT_NO_DRAGANDDROP QScopedPointer m_drag; diff --git a/src/plugins/platforms/openwfd/qopenwfdintegration.cpp b/src/plugins/platforms/openwfd/qopenwfdintegration.cpp index aeea035a3a..382ce82dc9 100644 --- a/src/plugins/platforms/openwfd/qopenwfdintegration.cpp +++ b/src/plugins/platforms/openwfd/qopenwfdintegration.cpp @@ -63,9 +63,7 @@ QOpenWFDIntegration::QOpenWFDIntegration() : QPlatformIntegration() , mPrinterSupport(new QGenericUnixPrinterSupport) - , mEventDispatcher(createUnixEventDispatcher()) { - QGuiApplicationPrivate::instance()->setEventDispatcher(mEventDispatcher); int numberOfDevices = wfdEnumerateDevices(0,0,0); WFDint devices[numberOfDevices]; @@ -119,9 +117,9 @@ QPlatformBackingStore *QOpenWFDIntegration::createPlatformBackingStore(QWindow * return new QOpenWFDBackingStore(window); } -QAbstractEventDispatcher *QOpenWFDIntegration::guiThreadEventDispatcher() const +QAbstractEventDispatcher *QOpenWFDIntegration::createEventDispatcher() const { - return mEventDispatcher; + return createUnixEventDispatcher(); } QPlatformFontDatabase *QOpenWFDIntegration::fontDatabase() const diff --git a/src/plugins/platforms/openwfd/qopenwfdintegration.h b/src/plugins/platforms/openwfd/qopenwfdintegration.h index 7118933841..9af91deeac 100644 --- a/src/plugins/platforms/openwfd/qopenwfdintegration.h +++ b/src/plugins/platforms/openwfd/qopenwfdintegration.h @@ -62,7 +62,7 @@ public: QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const; //This should not be a factory interface, but rather a accessor - QAbstractEventDispatcher *guiThreadEventDispatcher() const; + QAbstractEventDispatcher *createEventDispatcher() const; QPlatformFontDatabase *fontDatabase() const; @@ -78,7 +78,6 @@ private: QPlatformFontDatabase *mFontDatabase; QPlatformNativeInterface *mNativeInterface; QPlatformPrinterSupport *mPrinterSupport; - QAbstractEventDispatcher *mEventDispatcher; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index bd627fef0b..36a2194b56 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -294,6 +294,9 @@ QQnxIntegration::~QQnxIntegration() delete m_bpsEventFilter; #endif + // In case the event-dispatcher was never transferred to QCoreApplication + delete m_eventDispatcher; + delete m_screenEventHandler; // Destroy all displays @@ -386,10 +389,15 @@ void QQnxIntegration::moveToScreen(QWindow *window, int screen) platformWindow->setScreen(platformScreen); } -QAbstractEventDispatcher *QQnxIntegration::guiThreadEventDispatcher() const +QAbstractEventDispatcher *QQnxIntegration::createEventDispatcher() const { qIntegrationDebug() << Q_FUNC_INFO; - return m_eventDispatcher; + + // We transfer ownersip of the event-dispatcher to QtCoreApplication + QAbstractEventDispatcher *eventDispatcher = m_eventDispatcher; + m_eventDispatcher = 0; + + return eventDispatcher; } QPlatformNativeInterface *QQnxIntegration::nativeInterface() const diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h index dd8973b767..ab0d6a3156 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.h +++ b/src/plugins/platforms/qnx/qqnxintegration.h @@ -107,7 +107,7 @@ public: bool supportsNavigatorEvents() const; - QAbstractEventDispatcher *guiThreadEventDispatcher() const; + QAbstractEventDispatcher *createEventDispatcher() const; QPlatformFontDatabase *fontDatabase() const { return m_fontDatabase; } @@ -158,7 +158,7 @@ private: #endif QQnxServices *m_services; QPlatformFontDatabase *m_fontDatabase; - QAbstractEventDispatcher *m_eventDispatcher; + mutable QAbstractEventDispatcher *m_eventDispatcher; #if defined(Q_OS_BLACKBERRY) QQnxBpsEventFilter *m_bpsEventFilter; #endif diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index d7ac4cfc1e..b6e75929f8 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -315,7 +315,6 @@ struct QWindowsIntegrationPrivate QWindowsDrag m_drag; # endif #endif - QWindowsGuiEventDispatcher *m_eventDispatcher; #if defined(QT_OPENGL_ES_2) QEGLStaticContextPtr m_staticEGLContext; #elif !defined(QT_NO_OPENGL) @@ -356,7 +355,6 @@ static inline unsigned parseOptions(const QStringList ¶mList) QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mList) : m_options(parseOptions(paramList)) , m_fontDatabase(0) - , m_eventDispatcher(new QWindowsGuiEventDispatcher) { } @@ -369,7 +367,6 @@ QWindowsIntegrationPrivate::~QWindowsIntegrationPrivate() QWindowsIntegration::QWindowsIntegration(const QStringList ¶mList) : d(new QWindowsIntegrationPrivate(paramList)) { - QGuiApplicationPrivate::instance()->setEventDispatcher(d->m_eventDispatcher); #ifndef QT_NO_CLIPBOARD d->m_clipboard.registerViewer(); #endif @@ -635,9 +632,9 @@ QPlatformSessionManager *QWindowsIntegration::createPlatformSessionManager(const } #endif -QAbstractEventDispatcher * QWindowsIntegration::guiThreadEventDispatcher() const +QAbstractEventDispatcher * QWindowsIntegration::createEventDispatcher() const { - return d->m_eventDispatcher; + return new QWindowsGuiEventDispatcher; } QStringList QWindowsIntegration::themeNames() const diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h index 6643b1642e..97916a479b 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.h +++ b/src/plugins/platforms/windows/qwindowsintegration.h @@ -74,7 +74,7 @@ public: #ifndef QT_NO_OPENGL virtual QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const; #endif - virtual QAbstractEventDispatcher *guiThreadEventDispatcher() const; + virtual QAbstractEventDispatcher *createEventDispatcher() const; #ifndef QT_NO_CLIPBOARD virtual QPlatformClipboard *clipboard() const; # ifndef QT_NO_DRAGANDDROP diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index cef81ddfec..fc8f37cebe 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -124,12 +124,9 @@ static bool runningUnderDebugger() #endif QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char **argv) - : m_eventDispatcher(createUnixEventDispatcher()) - , m_services(new QGenericUnixServices) + : m_services(new QGenericUnixServices) , m_instanceName(0) { - QGuiApplicationPrivate::instance()->setEventDispatcher(m_eventDispatcher); - #ifdef XCB_USE_XLIB XInitThreads(); #endif @@ -293,9 +290,9 @@ bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const } } -QAbstractEventDispatcher *QXcbIntegration::guiThreadEventDispatcher() const +QAbstractEventDispatcher *QXcbIntegration::createEventDispatcher() const { - return m_eventDispatcher; + return createUnixEventDispatcher(); } void QXcbIntegration::moveToScreen(QWindow *window, int screen) diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h index 7ca7befc64..fd63fba5bf 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.h +++ b/src/plugins/platforms/xcb/qxcbintegration.h @@ -67,7 +67,7 @@ public: QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const; bool hasCapability(Capability cap) const; - QAbstractEventDispatcher *guiThreadEventDispatcher() const; + QAbstractEventDispatcher *createEventDispatcher() const; void moveToScreen(QWindow *window, int screen); @@ -112,7 +112,6 @@ private: QScopedPointer m_nativeInterface; QScopedPointer m_inputContext; - QAbstractEventDispatcher *m_eventDispatcher; #ifndef QT_NO_ACCESSIBILITY QScopedPointer m_accessibility; -- cgit v1.2.3