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/gui/kernel/qguiapplication.cpp | 8 ++++++++ src/gui/kernel/qguiapplication_p.h | 1 + src/gui/kernel/qplatformintegration.cpp | 12 ++++++++++++ src/gui/kernel/qplatformintegration.h | 1 + 4 files changed, 22 insertions(+) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index bde8d99a1c..c7eefdbefa 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1048,6 +1048,14 @@ void QGuiApplicationPrivate::createEventDispatcher() eventDispatcher = platform_integration->createEventDispatcher(); } +void QGuiApplicationPrivate::eventDispatcherReady() +{ + if (platform_integration == 0) + createPlatformIntegration(); + + platform_integration->initialize(); +} + #if defined(QT_DEBUG) && defined(Q_OS_LINUX) // Find out if our parent process is gdb by looking at the 'exe' symlink under /proc. static bool runningUnderDebugger() diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 91c63e54c5..d1716a6e28 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -84,6 +84,7 @@ public: void createPlatformIntegration(); void createEventDispatcher() Q_DECL_OVERRIDE; + void eventDispatcherReady() 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 3f93856349..22d6746ce0 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -290,6 +290,18 @@ QPaintEngine *QPlatformIntegration::createImagePaintEngine(QPaintDevice *paintDe return 0; } +/*! + Performs initialization steps that depend on having an event dispatcher + available. Called after the event dispatcher has been created. + + Tasks that require an event dispatcher, for example creating socket notifiers, cannot be + performed in the constructor. Instead, they should be performed here. The default + implementation does nothing. +*/ +void QPlatformIntegration::initialize() +{ +} + /*! Returns the platforms input context. diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index 0af74370b5..d3189f8641 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -112,6 +112,7 @@ public: // Event dispatcher: virtual QAbstractEventDispatcher *createEventDispatcher() const = 0; + virtual void initialize(); //Deeper window system integrations virtual QPlatformFontDatabase *fontDatabase() const; -- cgit v1.2.3