From cf092abdfc888f19a607a43c9b4bac776b5c1f8e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 2 Oct 2013 14:20:06 +0200 Subject: QPA: Fix event dispatcher dependent operations in platform integration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 999e5162ec3e86c9cb84c3ec95dfd0ba4b21277f breaks QPlatformIntegration implementations that perform tasks in their constructor that rely on the event dispatcher. For example creating a QSocketNotifier is not possible anymore since the event dispatcher is created later on. This is fixed by introducing an additional virtual in QPlatformIntegration that gets called after createEventDispatcher(). Two broken platform plugins have been identified so far: eglfs is creating socket notifiers to read events from input devices and xcb's input context plugins may use dbus. Both are updated accordingly. Task-number: QTBUG-33768 Change-Id: I5badb623958a52ab5314ff93dd7d60061f5df70a Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/eglfs/qeglfsintegration.cpp | 24 +++++++++++++++-------- src/plugins/platforms/eglfs/qeglfsintegration.h | 3 +++ src/plugins/platforms/xcb/qxcbintegration.cpp | 8 +++++++- src/plugins/platforms/xcb/qxcbintegration.h | 1 + 4 files changed, 27 insertions(+), 9 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index a6d964dcb0..45dccfa79f 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -80,13 +80,8 @@ static void *eglContextForContext(QOpenGLContext *context); QEglFSIntegration::QEglFSIntegration() : mFontDb(new QGenericUnixFontDatabase) , mServices(new QGenericUnixServices) + , mInputContext(0) { -#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); - new QEvdevTouchScreenHandlerThread(QString() /* spec */, this); -#endif - QEglFSHooks::hooks()->platformInit(); EGLint major, minor; @@ -109,8 +104,6 @@ QEglFSIntegration::QEglFSIntegration() mScreen = new QEglFSScreen(mDisplay); screenAdded(mScreen); - - mInputContext = QPlatformInputContextFactory::create(); } QEglFSIntegration::~QEglFSIntegration() @@ -170,6 +163,12 @@ QAbstractEventDispatcher *QEglFSIntegration::createEventDispatcher() const return createUnixEventDispatcher(); } +void QEglFSIntegration::initialize() +{ + mInputContext = QPlatformInputContextFactory::create(); + createInputHandlers(); +} + QVariant QEglFSIntegration::styleHint(QPlatformIntegration::StyleHint hint) const { switch (hint) @@ -309,4 +308,13 @@ EGLConfig QEglFSIntegration::chooseConfig(EGLDisplay display, const QSurfaceForm return chooser.chooseConfig(); } +void QEglFSIntegration::createInputHandlers() +{ +#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); + new QEvdevTouchScreenHandlerThread(QString() /* spec */, this); +#endif +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.h b/src/plugins/platforms/eglfs/qeglfsintegration.h index 4e24e2f2f7..a6fcfc8427 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.h +++ b/src/plugins/platforms/eglfs/qeglfsintegration.h @@ -68,6 +68,7 @@ public: QPlatformServices *services() const; QAbstractEventDispatcher *createEventDispatcher() const; + void initialize(); QVariant styleHint(QPlatformIntegration::StyleHint hint) const; @@ -86,6 +87,8 @@ public: QPlatformInputContext *inputContext() const { return mInputContext; } private: + void createInputHandlers(); + EGLDisplay mDisplay; QScopedPointer mFontDb; QScopedPointer mServices; diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 2249446242..5168bd818b 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -172,7 +172,6 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char } m_fontDatabase.reset(new QGenericUnixFontDatabase()); - m_inputContext.reset(QPlatformInputContextFactory::create()); } QXcbIntegration::~QXcbIntegration() @@ -292,6 +291,13 @@ QAbstractEventDispatcher *QXcbIntegration::createEventDispatcher() const return createUnixEventDispatcher(); } +void QXcbIntegration::initialize() +{ + // Perform everything that may potentially need the event dispatcher (timers, socket + // notifiers) here instead of the constructor. + m_inputContext.reset(QPlatformInputContextFactory::create()); +} + void QXcbIntegration::moveToScreen(QWindow *window, int screen) { Q_UNUSED(window); diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h index 008d03fbcb..79fb1965c4 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.h +++ b/src/plugins/platforms/xcb/qxcbintegration.h @@ -68,6 +68,7 @@ public: bool hasCapability(Capability cap) const; QAbstractEventDispatcher *createEventDispatcher() const; + void initialize(); void moveToScreen(QWindow *window, int screen); -- cgit v1.2.3