Remove QPlatformEventLoopIntegration.
authorMorten Sorvig <morten.sorvig@nokia.com>
Thu, 9 Jun 2011 09:13:49 +0000 (11:13 +0200)
committerMorten Sorvig <morten.sorvig@nokia.com>
Thu, 9 Jun 2011 09:19:12 +0000 (11:19 +0200)
Instead we'll let the platform plugins construct
an QEventDispatcherQPA subclass. This API will be
added later on.

This temporarily breaks cocoa, uikit and opencode.

src/gui/kernel/kernel.pri
src/gui/kernel/qeventdispatcher_glib_qpa.cpp
src/gui/kernel/qeventdispatcher_glib_qpa_p.h
src/gui/kernel/qeventdispatcher_qpa.cpp
src/gui/kernel/qeventdispatcher_qpa_p.h
src/gui/kernel/qplatformeventloopintegration_qpa.cpp [deleted file]
src/gui/kernel/qplatformeventloopintegration_qpa.h [deleted file]
src/gui/kernel/qplatformintegration_qpa.cpp
src/gui/kernel/qplatformintegration_qpa.h
src/tools/uic/qclass_lib_map.h

index b7c49a3..7d31401 100644 (file)
@@ -49,7 +49,6 @@ qpa {
                 kernel/qplatformwindow_qpa.h \
                 kernel/qplatformglcontext_qpa.h \
                 kernel/qwindowcontext_qpa.h \
-                kernel/qplatformeventloopintegration_qpa.h \
                 kernel/qplatformcursor_qpa.h \
                 kernel/qplatformclipboard_qpa.h \
                 kernel/qplatformnativeinterface_qpa.h \
@@ -71,7 +70,6 @@ qpa {
                 kernel/qplatformintegrationfactory_qpa.cpp \
                 kernel/qplatformintegrationplugin_qpa.cpp \
                 kernel/qplatformwindow_qpa.cpp \
-                kernel/qplatformeventloopintegration_qpa.cpp \
                 kernel/qplatformglcontext_qpa.cpp \
                 kernel/qwindowcontext_qpa.cpp \
                 kernel/qplatformcursor_qpa.cpp \
index 2c00fe8..eea0b93 100644 (file)
@@ -130,17 +130,4 @@ QPAEventDispatcherGlib::~QPAEventDispatcherGlib()
     d->userEventSource = 0;
 }
 
-bool QPAEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags)
-{
-    static bool init = false;
-    if (!init) {
-        if (QGuiApplicationPrivate::platformIntegration()->createEventLoopIntegration()) {
-            qWarning("Eventloop integration is not supported by the glib event dispatcher");
-            qWarning("Use the UNIX event dispatcher by defining environment variable QT_NO_GLIB=1");
-        }
-        init = true;
-    }
-    return QEventDispatcherGlib::processEvents(flags);
-}
-
 QT_END_NAMESPACE
index 8a8559d..ec9bb5e 100644 (file)
@@ -68,8 +68,6 @@ class QPAEventDispatcherGlib : public QEventDispatcherGlib
 public:
     explicit QPAEventDispatcherGlib(QObject *parent = 0);
     ~QPAEventDispatcherGlib();
-
-    bool processEvents(QEventLoop::ProcessEventsFlags flags);
 };
 
 struct GUserEventSource;
index d769b22..b3f41bf 100644 (file)
@@ -43,7 +43,6 @@
 #include "qcoreapplication.h"
 #include "qeventdispatcher_qpa_p.h"
 #include "private/qguiapplication_p.h"
-#include "qplatformeventloopintegration_qpa.h"
 
 #include <QWindowSystemInterface>
 #include <QtCore/QElapsedTimer>
@@ -58,142 +57,25 @@ QT_BEGIN_NAMESPACE
 
 QT_USE_NAMESPACE
 
-class Rendezvous
+QEventDispatcherQPAPrivate::QEventDispatcherQPAPrivate()
 {
-public:
-    void checkpoint()
-    {
-        if (state.testAndSetOrdered(0,1)) {
-            semaphore.acquire();
-        } else if (state.testAndSetAcquire(1,0)) {
-            semaphore.release();
-        } else {
-            qWarning("Barrier internal error");
-        }
-    }
-private:
-    QSemaphore semaphore;
-    QAtomicInt state;
-};
-
-class SelectWorker : public QThread
-{
-public:
-    SelectWorker(QEventDispatcherQPAPrivate *eventDispatcherPrivate)
-        : QThread(),
-          m_edPrivate(eventDispatcherPrivate),
-          m_retVal(0)
-    {
-    }
-
-    void setSelectValues(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
-    {
-        m_nfds = nfds;
-        m_readfds = readfds;
-        m_writefds = writefds;
-        m_exceptfds = exceptfds;
-
 
-    }
-
-    int retVal() const {
-        return m_retVal;
-    }
-
-protected:
-    void run();
-
-private:
-    QEventDispatcherQPAPrivate *m_edPrivate;
-    int m_retVal;
-
-    int m_nfds;
-    fd_set *m_readfds, *m_writefds, *m_exceptfds;
-};
+}
 
-class QEventDispatcherQPAPrivate : public EVENTDISPATCHERBASEPRIVATE
+QEventDispatcherQPAPrivate::~QEventDispatcherQPAPrivate()
 {
-    Q_DECLARE_PUBLIC(QEventDispatcherQPA)
-public:
-    QEventDispatcherQPAPrivate()
-        :  eventLoopIntegration(0),
-           barrierBeforeBlocking(0),
-           barrierReturnValue(0),
-           selectReturnMutex(0),
-           selectWorkerNeedsSync(true),
-           selectWorkerHasResult(false),
-           m_integrationInitialised(false),
-           m_hasIntegration(false),
-           m_isEventLoopIntegrationRunning(false)
-    {
 
-    }
-
-    ~QEventDispatcherQPAPrivate()
-    {
-        delete selectWorker;
-        delete eventLoopIntegration;
-        delete barrierBeforeBlocking;
-        delete barrierReturnValue;
-        delete selectReturnMutex;
-    }
-
-    bool hasIntegration() const
-    {
-        if (!m_integrationInitialised) {
-            QEventDispatcherQPAPrivate *that = const_cast<QEventDispatcherQPAPrivate *>(this);
-            if (qApp && (qApp->thread() == QThread::currentThread())) { // guiThread
-                if (QGuiApplicationPrivate::platformIntegration()) {
-                    that->eventLoopIntegration = QGuiApplicationPrivate::platformIntegration()->createEventLoopIntegration();
-                    if (that->eventLoopIntegration) {
-                        that->selectWorker = new SelectWorker(that);
-                        that->barrierBeforeBlocking = new Rendezvous;
-                        that->barrierReturnValue = new Rendezvous;
-                        that->selectReturnMutex = new QMutex;
-                        that->selectWorker->start();
-                        that->m_hasIntegration = true;
-                        if (!QElapsedTimer::isMonotonic())
-                            qWarning("Having eventloop integration without monotonic timers can lead to undefined behaviour");
-                    }
-                }
-            }
-            that->m_integrationInitialised = true;
-        }
-        return m_hasIntegration;
-    }
-
-    bool isEventLoopIntegrationRunning() const
-    {
-        return m_isEventLoopIntegrationRunning;
-    }
-
-    void runEventLoopIntegration()
-    {
-        if (qApp && (qApp->thread() == QThread::currentThread())) {
-            m_isEventLoopIntegrationRunning = true;
-            eventLoopIntegration->startEventLoop();
-        }
-    }
-
-    QPlatformEventLoopIntegration *eventLoopIntegration;
-    Rendezvous *barrierBeforeBlocking;
-    Rendezvous *barrierReturnValue;
-
-    QMutex *selectReturnMutex;
-    bool selectWorkerNeedsSync;
-    bool selectWorkerHasResult;
-
-    SelectWorker *selectWorker;
-private:
-    bool m_integrationInitialised;
-    bool m_hasIntegration;
-    bool m_isEventLoopIntegrationRunning;
-};
+}
 
 QEventDispatcherQPA::QEventDispatcherQPA(QObject *parent)
     : EVENTDISPATCHERBASE(*new QEventDispatcherQPAPrivate, parent)
 { }
 
+QEventDispatcherQPA::QEventDispatcherQPA(QEventDispatcherUNIXPrivate &priv, QObject *parent)
+    : EVENTDISPATCHERBASE(priv, parent)
+{ }
+
+
 QEventDispatcherQPA::~QEventDispatcherQPA()
 { }
 
@@ -201,16 +83,6 @@ bool QEventDispatcherQPA::processEvents(QEventLoop::ProcessEventsFlags flags)
 {
     Q_D(QEventDispatcherQPA);
 
-    if (d->hasIntegration()) {
-        if (!d->isEventLoopIntegrationRunning()) {
-            d->runEventLoopIntegration();
-        }
-        if (d->threadData->quitNow) {
-            d->eventLoopIntegration->quitEventLoop();
-            return false;
-        }
-    }
-
     int nevents = 0;
 
     // handle gui and posted events
@@ -254,89 +126,10 @@ bool QEventDispatcherQPA::hasPendingEvents()
     return qGlobalPostedEventsCount() || QWindowSystemInterfacePrivate::windowSystemEventsQueued();
 }
 
-void QEventDispatcherQPA::registerSocketNotifier(QSocketNotifier *notifier)
-{
-    Q_D(QEventDispatcherQPA);
-    EVENTDISPATCHERBASE::registerSocketNotifier(notifier);
-    if (d->hasIntegration())
-        wakeUp();
-
-}
-
-void QEventDispatcherQPA::unregisterSocketNotifier(QSocketNotifier *notifier)
-{
-    Q_D(QEventDispatcherQPA);
-    EVENTDISPATCHERBASE::unregisterSocketNotifier(notifier);
-    if (d->hasIntegration())
-        wakeUp();
-}
-
 void QEventDispatcherQPA::flush()
 {
     if(qApp)
         qApp->sendPostedEvents();
 }
 
-int QEventDispatcherQPA::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
-                                timeval *timeout)
-{
-    Q_D(QEventDispatcherQPA);
-    int retVal = 0;
-    if (d->hasIntegration()) {
-        qint64 timeoutmsec = 0;
-        if (timeout)
-            timeoutmsec = timeout->tv_sec * 1000 + (timeout->tv_usec/1000);
-        d->selectReturnMutex->lock();
-        if (d->selectWorkerNeedsSync) {
-            if (d->selectWorkerHasResult) {
-                retVal = d->selectWorker->retVal();
-                d->selectWorkerHasResult = false;
-
-                d->selectReturnMutex->unlock();
-                d->barrierReturnValue->checkpoint();
-                d->eventLoopIntegration->setNextTimerEvent(0);
-                return retVal;
-            } else {
-                d->selectWorkerNeedsSync = false;
-                d->selectWorker->setSelectValues(nfds,readfds, writefds, exceptfds);
-                d->barrierBeforeBlocking->checkpoint();
-            }
-        }
-        d->selectReturnMutex->unlock();
-        d->eventLoopIntegration->setNextTimerEvent(timeoutmsec);
-        retVal = 0; //is 0 if select has not returned
-    } else {
-#if defined(Q_OS_UNIX)
-        retVal = EVENTDISPATCHERBASE::select(nfds, readfds, writefds, exceptfds, timeout);
-#elif defined(Q_OS_WIN)
-        // ### TODO
-#endif
-    }
-    return retVal;
-}
-
-
-void SelectWorker::run()
-{
-
-    while(true) {
-        m_retVal = 0;
-        m_edPrivate->barrierBeforeBlocking->checkpoint(); // wait for mainthread
-#if defined(Q_OS_UNIX)
-        int tmpRet = qt_safe_select(m_nfds,m_readfds,m_writefds,m_exceptfds,0);
-#elif defined(Q_OS_WIN)
-        // ### TODO
-        int tmpRet = 0;
-#endif
-        m_edPrivate->selectReturnMutex->lock();
-        m_edPrivate->eventLoopIntegration->qtNeedsToProcessEvents();
-
-        m_edPrivate->selectWorkerNeedsSync = true;
-        m_edPrivate->selectWorkerHasResult = true;
-        m_retVal = tmpRet;
-
-        m_edPrivate->selectReturnMutex->unlock();
-        m_edPrivate->barrierReturnValue->checkpoint();
-    }
-}
 QT_END_NAMESPACE
index c4a2221..f1eab6d 100644 (file)
@@ -75,19 +75,21 @@ class QEventDispatcherQPA : public EVENTDISPATCHERBASE
 
 public:
     explicit QEventDispatcherQPA(QObject *parent = 0);
+    QEventDispatcherQPA(QEventDispatcherUNIXPrivate &priv, QObject *parent);
     ~QEventDispatcherQPA();
 
     bool processEvents(QEventLoop::ProcessEventsFlags flags);
     bool hasPendingEvents();
 
-    void registerSocketNotifier(QSocketNotifier *notifier);
-    void unregisterSocketNotifier(QSocketNotifier *notifier);
-
     void flush();
+};
 
-protected:
-    int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
-               timeval *timeout);
+class QEventDispatcherQPAPrivate : public EVENTDISPATCHERBASEPRIVATE
+{
+    Q_DECLARE_PUBLIC(QEventDispatcherQPA)
+public:
+    QEventDispatcherQPAPrivate();
+    ~QEventDispatcherQPAPrivate();
 };
 
 QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformeventloopintegration_qpa.cpp b/src/gui/kernel/qplatformeventloopintegration_qpa.cpp
deleted file mode 100644 (file)
index a79b03e..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformeventloopintegration_qpa.h"
-
-#include <QtCore/QCoreApplication>
-
-#include <QtCore/QDebug>
-
-class QPlatformEventLoopIntegrationPrivate
-{
-public:
-    QPlatformEventLoopIntegrationPrivate();
-    qint64 nextTimerEvent;
-};
-
-QPlatformEventLoopIntegrationPrivate::QPlatformEventLoopIntegrationPrivate()
-    : nextTimerEvent(0)
-{
-}
-
-QPlatformEventLoopIntegration::QPlatformEventLoopIntegration()
-    : d_ptr(new QPlatformEventLoopIntegrationPrivate)
-
-{
-}
-
-QPlatformEventLoopIntegration::~QPlatformEventLoopIntegration()
-{
-}
-
-qint64 QPlatformEventLoopIntegration::nextTimerEvent() const
-{
-    Q_D(const QPlatformEventLoopIntegration);
-    return d->nextTimerEvent;
-}
-
-
-void QPlatformEventLoopIntegration::setNextTimerEvent(qint64 nextTimerEvent)
-{
-    Q_D(QPlatformEventLoopIntegration);
-    d->nextTimerEvent = nextTimerEvent;
-}
-
-void QPlatformEventLoopIntegration::processEvents()
-{
-    QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents);
-}
diff --git a/src/gui/kernel/qplatformeventloopintegration_qpa.h b/src/gui/kernel/qplatformeventloopintegration_qpa.h
deleted file mode 100644 (file)
index 16a7cfd..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLATFORMEVENTLOOPINTEGRATION_QPA_H
-#define QPLATFORMEVENTLOOPINTEGRATION_QPA_H
-
-#include <QtCore/qglobal.h>
-#include <QtCore/QScopedPointer>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QPlatformEventLoopIntegrationPrivate;
-
-class Q_GUI_EXPORT QPlatformEventLoopIntegration
-{
-    Q_DECLARE_PRIVATE(QPlatformEventLoopIntegration);
-public:
-    QPlatformEventLoopIntegration();
-    virtual ~QPlatformEventLoopIntegration();
-
-    virtual void startEventLoop() = 0;
-    virtual void quitEventLoop() = 0;
-    virtual void qtNeedsToProcessEvents() = 0;
-
-    qint64 nextTimerEvent() const;
-    void setNextTimerEvent(qint64 nextTimerEvent);
-
-    static void processEvents();
-protected:
-    QScopedPointer<QPlatformEventLoopIntegrationPrivate> d_ptr;
-private:
-    Q_DISABLE_COPY(QPlatformEventLoopIntegration);
-    friend class QEventDispatcherQPA;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QPLATFORMEVENTLOOPINTEGRATION_QPA_H
index 7dadf70..19bac35 100644 (file)
@@ -58,17 +58,6 @@ QPixmap QPlatformIntegration::grabWindow(WId window, int x, int y, int width, in
     return QPixmap();
 }
 
-/*!
-    Factory function for the eventloop integration interface.
-
-    Default implementation returns 0, which causes the eventloop to run in a single thread mode.
-
-    \sa QPlatformEventLoopIntegration
-*/
-QPlatformEventLoopIntegration *QPlatformIntegration::createEventLoopIntegration() const
-{
-    return 0;
-}
 
 /*!
     Accessor for the platform integrations fontdatabase.
index 1a96d84..053605b 100644 (file)
@@ -56,7 +56,6 @@ QT_MODULE(Gui)
 class QPlatformWindow;
 class QWindow;
 class QBlittable;
-class QPlatformEventLoopIntegration;
 class QPlatformFontDatabase;
 class QPlatformClipboard;
 class QPlatformNativeInterface;
@@ -95,11 +94,6 @@ public:
     virtual QPlatformDrag *drag() const;
 #endif
 
-// Experimental in mainthread eventloop integration
-// This should only be used if it is only possible to do window system event processing in
-// the gui thread. All of the functions in QWindowSystemInterface are thread safe.
-    virtual QPlatformEventLoopIntegration *createEventLoopIntegration() const;
-
 // Access native handles. The window handle is already available from Wid;
     virtual QPlatformNativeInterface *nativeInterface() const;
 
index 216ab7e..d44d344 100644 (file)
@@ -823,7 +823,6 @@ QT_CLASS_LIB(QColorGroup, QtWidgets, qpalette.h)
 QT_CLASS_LIB(QPlatformCursorImage, QtGui, qplatformcursor_qpa.h)
 QT_CLASS_LIB(QPlatformCursorPrivate, QtGui, qplatformcursor_qpa.h)
 QT_CLASS_LIB(QPlatformCursor, QtGui, qplatformcursor_qpa.h)
-QT_CLASS_LIB(QPlatformEventLoopIntegration, QtGui, qplatformeventloopintegration_qpa.h)
 QT_CLASS_LIB(QPlatformGLContext, QtGui, qplatformglcontext_qpa.h)
 QT_CLASS_LIB(QPlatformIntegration, QtGui, qplatformintegration_qpa.h)
 QT_CLASS_LIB(QPlatformIntegrationFactoryInterface, QtGui, qplatformintegrationplugin_qpa.h)