Make it possible to use QSocketNotifier in Lighthouse plugins
authorJørgen Lind <jorgen.lind@nokia.com>
Thu, 21 Jul 2011 11:11:55 +0000 (13:11 +0200)
committerSamuel Rødal <samuel.rodal@nokia.com>
Wed, 27 Jul 2011 13:47:49 +0000 (15:47 +0200)
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 <qt_sanity_bot@ovi.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/gui/kernel/qguiapplication.cpp
src/gui/kernel/qguiapplication_p.h

index 5f96ac3..5a31fb5 100644 (file)
@@ -50,6 +50,7 @@
 #include <QtCore/private/qcoreapplication_p.h>
 #include <QtCore/private/qabstracteventdispatcher_p.h>
 #include <QtCore/qmutex.h>
+#include <QtCore/private/qthread_p.h>
 #include <QtDebug>
 #include <qpalette.h>
 #include <qscreen.h>
@@ -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()
index a08dbca..325c89e 100644 (file)
@@ -69,6 +69,7 @@ public:
 
     void createPlatformIntegration();
     void createEventDispatcher();
+    void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);
 
     virtual void notifyLayoutDirectionChange();
     virtual void notifyActiveWindowChange(QWindow *previous);