diff options
Diffstat (limited to 'src')
32 files changed, 91 insertions, 116 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index b242a3cc68..8e5c290cc6 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1029,27 +1029,23 @@ void QGuiApplicationPrivate::createPlatformIntegration() } +/*! + Called from QCoreApplication::init() + + Responsible for creating an event dispatcher when QCoreApplication + decides that it needs one (because a custom one has not been set). +*/ void QGuiApplicationPrivate::createEventDispatcher() { + Q_ASSERT(!eventDispatcher); + if (platform_integration == 0) createPlatformIntegration(); - if (!eventDispatcher) { - QAbstractEventDispatcher *eventDispatcher = platform_integration->guiThreadEventDispatcher(); - setEventDispatcher(eventDispatcher); - } -} - -void QGuiApplicationPrivate::setEventDispatcher(QAbstractEventDispatcher *eventDispatcher) -{ - Q_Q(QGuiApplication); - - if (!QCoreApplicationPrivate::eventDispatcher) { - QCoreApplicationPrivate::eventDispatcher = eventDispatcher; - QCoreApplicationPrivate::eventDispatcher->setParent(q); - threadData->eventDispatcher = eventDispatcher; - } + // The platform integration should not mess with the event dispatcher + Q_ASSERT(!eventDispatcher); + eventDispatcher = platform_integration->createEventDispatcher(); } #if defined(QT_DEBUG) && defined(Q_OS_LINUX) diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 7a4a161476..91c63e54c5 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -83,8 +83,7 @@ public: ~QGuiApplicationPrivate(); void createPlatformIntegration(); - void createEventDispatcher(); - void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher); + void createEventDispatcher() Q_DECL_OVERRIDE; virtual void notifyLayoutDirectionChange(); virtual void notifyActiveWindowChange(QWindow *previous); diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index dc775bcb61..3f93856349 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -231,17 +231,23 @@ QPlatformServices *QPlatformIntegration::services() const are never repositioned by the window manager. The default implementation returns true. */ - /*! - \fn QAbstractEventDispatcher *QPlatformIntegration::guiThreadEventDispatcher() const = 0 + \fn QAbstractEventDispatcher *QPlatformIntegration::createEventDispatcher() const = 0 + + Factory function for the GUI event dispatcher. The platform plugin should create + and return a QAbstractEventDispatcher subclass when this function is called. + + If the platform plugin for some reason creates the event dispatcher outside of + this function (for example in the constructor), it needs to handle the case + where this function is never called, ensuring that the event dispatcher is + still deleted at some point (typically in the destructor). + + Note that the platform plugin should never explicitly set the event dispatcher + itself, using QCoreApplication::setEventDispatcher(), but let QCoreApplication + decide when and which event dispatcher to create. - Accessor function for the event dispatcher. The platform plugin should create - an instance of the QAbstractEventDispatcher in its constructor and set it - on the application using QGuiApplicationPrivate::instance()->setEventDispatcher(). - The event dispatcher is owned by QGuiApplication, the accessor should return - a flat pointer. - \sa QGuiApplicationPrivate + \since 5.2 */ bool QPlatformIntegration::hasCapability(Capability cap) const diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index 0204181ca6..0af74370b5 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -111,7 +111,7 @@ public: virtual QPaintEngine *createImagePaintEngine(QPaintDevice *paintDevice) const; // Event dispatcher: - virtual QAbstractEventDispatcher *guiThreadEventDispatcher() const = 0; + virtual QAbstractEventDispatcher *createEventDispatcher() const = 0; //Deeper window system integrations virtual QPlatformFontDatabase *fontDatabase() const; 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<QPlatformFontDatabase> mFontDb; - QAbstractEventDispatcher *mEventDispatcher; QScopedPointer<QPlatformInputContext> 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<QDirectFbInput> m_input; QScopedPointer<QThread> m_inputRunner; QScopedPointer<QPlatformFontDatabase> 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<QPlatformFontDatabase> mFontDb; QScopedPointer<QPlatformServices> 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<QPlatformScreen *> m_screens; QList<QKmsDevice *> 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<QPlatformScreen *> 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<QPlatformScreen *> 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<QEventDispatcherWin32>(); 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<QEventDispatcherWin32>(); +#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<QPlatformFontDatabase> m_fontDatabase; #ifndef QT_NO_DRAGANDDROP QScopedPointer<QPlatformDrag> 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<QXcbNativeInterface> m_nativeInterface; QScopedPointer<QPlatformInputContext> m_inputContext; - QAbstractEventDispatcher *m_eventDispatcher; #ifndef QT_NO_ACCESSIBILITY QScopedPointer<QPlatformAccessibility> m_accessibility; |