summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2013-10-02 14:20:06 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-07 19:09:37 +0200
commitcf092abdfc888f19a607a43c9b4bac776b5c1f8e (patch)
treedeaef143d4e310d73f0fbf7e839ddbd1c7cf2eb1 /src
parent8a383c585f337320a203e26c505b594c949d59e5 (diff)
QPA: Fix event dispatcher dependent operations in platform integration
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ø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp5
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h1
-rw-r--r--src/gui/kernel/qguiapplication.cpp8
-rw-r--r--src/gui/kernel/qguiapplication_p.h1
-rw-r--r--src/gui/kernel/qplatformintegration.cpp12
-rw-r--r--src/gui/kernel/qplatformintegration.h1
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.cpp24
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.h3
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp8
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h1
10 files changed, 55 insertions, 9 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 71ff47eab8..115f7bc04e 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -479,6 +479,10 @@ void QCoreApplicationPrivate::createEventDispatcher()
#endif
}
+void QCoreApplicationPrivate::eventDispatcherReady()
+{
+}
+
QThread *QCoreApplicationPrivate::theMainThread = 0;
QThread *QCoreApplicationPrivate::mainThread()
{
@@ -714,6 +718,7 @@ void QCoreApplication::init()
}
d->threadData->eventDispatcher = QCoreApplicationPrivate::eventDispatcher;
+ d->eventDispatcherReady();
#endif
#ifndef QT_NO_LIBRARY
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index 477b8cfcfe..4b57a7b67d 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -99,6 +99,7 @@ public:
bool notify_helper(QObject *, QEvent *);
virtual void createEventDispatcher();
+ virtual void eventDispatcherReady();
static void removePostedEvent(QEvent *);
#ifdef Q_OS_WIN
static void removePostedTimerEvent(QObject *object, int timerId);
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
@@ -291,6 +291,18 @@ QPaintEngine *QPlatformIntegration::createImagePaintEngine(QPaintDevice *paintDe
}
/*!
+ 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.
The default implementation returns 0, implying no input method support.
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;
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<QPlatformFontDatabase> mFontDb;
QScopedPointer<QPlatformServices> 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 &parameters, 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);