summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qguiapplication.cpp26
-rw-r--r--src/gui/kernel/qguiapplication_p.h3
-rw-r--r--src/gui/kernel/qplatformintegration.cpp22
-rw-r--r--src/gui/kernel/qplatformintegration.h2
4 files changed, 27 insertions, 26 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;