From 86e7c36b504f7c92229229747bdc5587b298a81c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 21 Jul 2011 13:11:55 +0200 Subject: Make it possible to use QSocketNotifier in Lighthouse plugins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The idea is that now the plugin can register the event dispatcher in its constructor, so it can freely use QSocketNotifier or what not. If the plugin choses not to do so, then the createFunction will be called at a later point. Change-Id: I75fb2ee4180d9619ac94e75fbcf1efd7a2deecbc Reviewed-on: http://codereview.qt.nokia.com/2287 Reviewed-by: Qt Sanity Bot Reviewed-by: Samuel Rødal --- src/gui/kernel/qguiapplication.cpp | 21 +++++++++++++++++---- src/gui/kernel/qguiapplication_p.h | 1 + 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 5f96ac3493..5a31fb5df1 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -313,13 +314,25 @@ void QGuiApplicationPrivate::createPlatformIntegration() void QGuiApplicationPrivate::createEventDispatcher() { - Q_Q(QGuiApplication); - if (platform_integration == 0) createPlatformIntegration(); - eventDispatcher = platform_integration->createEventDispatcher(); - eventDispatcher->setParent(q); + if (!eventDispatcher) { + QAbstractEventDispatcher *eventDispatcher = platform_integration->createEventDispatcher(); + setEventDispatcher(eventDispatcher); + } +} + +void QGuiApplicationPrivate::setEventDispatcher(QAbstractEventDispatcher *eventDispatcher) +{ + Q_Q(QGuiApplication); + + if (!this->eventDispatcher) { + this->eventDispatcher = eventDispatcher; + this->eventDispatcher->setParent(q); + threadData->eventDispatcher = eventDispatcher; + } + } void QGuiApplicationPrivate::init() diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index a08dbca4f1..325c89e363 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -69,6 +69,7 @@ public: void createPlatformIntegration(); void createEventDispatcher(); + void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher); virtual void notifyLayoutDirectionChange(); virtual void notifyActiveWindowChange(QWindow *previous); -- cgit v1.2.3