Make xcb work again after event dispatcher changes.
authorMorten Johan Sorvig <morten.sorvig@nokia.com>
Wed, 22 Jun 2011 09:33:17 +0000 (11:33 +0200)
committerMorten Johan Sorvig <morten.sorvig@nokia.com>
Wed, 22 Jun 2011 09:37:42 +0000 (11:37 +0200)
The platform plugin/event dispatcher creation order
has now been reversed and the event dispatcher
cannot be accessed during plugin construciton.

src/gui/kernel/qguiapplication.cpp
src/plugins/platforms/xcb/qxcbconnection.cpp
src/plugins/platforms/xcb/qxcbconnection.h
src/plugins/platforms/xcb/qxcbintegration.cpp

index e3a2b58..00c38ea 100644 (file)
@@ -287,7 +287,6 @@ void QGuiApplicationPrivate::createEventDispatcher()
 
 void QGuiApplicationPrivate::init()
 {
-    qDebug() << "QGuiApplicationPrivate::init";
     QList<QByteArray> pluginList;
     // Get command line params
 
index ac8a900..1e18077 100644 (file)
@@ -138,14 +138,6 @@ QXcbConnection::QXcbConnection(const char *displayName)
 #ifdef XCB_USE_DRI2
     initializeDri2();
 #endif
-
-    QSocketNotifier *notifier = new QSocketNotifier(xcb_get_file_descriptor(xcb_connection()), QSocketNotifier::Read, this);
-    connect(notifier, SIGNAL(activated(int)), this, SLOT(processXcbEvents()));
-
-    QAbstractEventDispatcher *dispatcher = QAbstractEventDispatcher::instance(qApp->thread());
-    connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(processXcbEvents()));
-    connect(dispatcher, SIGNAL(awake()), this, SLOT(processXcbEvents()));
-
     sync();
 }
 
@@ -164,6 +156,15 @@ QXcbConnection::~QXcbConnection()
     delete m_keyboard;
 }
 
+void QXcbConnection::setEventDispatcher(QAbstractEventDispatcher *dispatcher)
+{
+    QSocketNotifier *notifier = new QSocketNotifier(xcb_get_file_descriptor(xcb_connection()), QSocketNotifier::Read, this);
+    connect(notifier, SIGNAL(activated(int)), this, SLOT(processXcbEvents()));
+
+    connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(processXcbEvents()));
+    connect(dispatcher, SIGNAL(awake()), this, SLOT(processXcbEvents()));
+}
+
 void QXcbConnection::addWindow(xcb_window_t id, QXcbWindow *window)
 {
     m_mapper.insert(id, window);
index 6cc7e13..bc90f5f 100644 (file)
@@ -222,6 +222,7 @@ namespace QXcbAtom {
     };
 }
 
+class QAbstractEventDispatcher;
 class QXcbConnection : public QObject
 {
     Q_OBJECT
@@ -231,6 +232,8 @@ public:
 
     QXcbConnection *connection() const { return const_cast<QXcbConnection *>(this); }
 
+    void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);
+
     const QList<QXcbScreen *> &screens() const { return m_screens; }
     int primaryScreen() const { return m_primaryScreen; }
 
index 2513075..984c8af 100644 (file)
@@ -139,7 +139,9 @@ QPlatformBackingStore *QXcbIntegration::createPlatformBackingStore(QWindow *wind
 
 QAbstractEventDispatcher *QXcbIntegration::createEventDispatcher() const
 {
-    return createUnixEventDispatcher();
+    QAbstractEventDispatcher *eventDispatcher = createUnixEventDispatcher();
+    m_connection->setEventDispatcher(eventDispatcher);
+    return eventDispatcher;
 }
 
 QList<QPlatformScreen *> QXcbIntegration::screens() const