summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Sorvig <morten.sorvig@nokia.com>2011-06-09 11:13:49 +0200
committerMorten Sorvig <morten.sorvig@nokia.com>2011-06-09 11:19:12 +0200
commit0a4c2eae4bd5fcbf1ac3d91e7870def7e8b4a66b (patch)
tree9aaa49d6b6be942c4a84f2742633375ec563ba4e
parentd88a773218468c6532b2bb563540d1fe1c5f5376 (diff)
Remove QPlatformEventLoopIntegration.
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.
-rw-r--r--src/gui/kernel/kernel.pri2
-rw-r--r--src/gui/kernel/qeventdispatcher_glib_qpa.cpp13
-rw-r--r--src/gui/kernel/qeventdispatcher_glib_qpa_p.h2
-rw-r--r--src/gui/kernel/qeventdispatcher_qpa.cpp225
-rw-r--r--src/gui/kernel/qeventdispatcher_qpa_p.h14
-rw-r--r--src/gui/kernel/qplatformeventloopintegration_qpa.cpp86
-rw-r--r--src/gui/kernel/qplatformeventloopintegration_qpa.h82
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.cpp11
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.h6
-rw-r--r--src/tools/uic/qclass_lib_map.h1
10 files changed, 17 insertions, 425 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index b7c49a3db8..7d3140143e 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -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 \
diff --git a/src/gui/kernel/qeventdispatcher_glib_qpa.cpp b/src/gui/kernel/qeventdispatcher_glib_qpa.cpp
index 2c00fe8734..eea0b9333e 100644
--- a/src/gui/kernel/qeventdispatcher_glib_qpa.cpp
+++ b/src/gui/kernel/qeventdispatcher_glib_qpa.cpp
@@ -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
diff --git a/src/gui/kernel/qeventdispatcher_glib_qpa_p.h b/src/gui/kernel/qeventdispatcher_glib_qpa_p.h
index 8a8559dfb4..ec9bb5e0ef 100644
--- a/src/gui/kernel/qeventdispatcher_glib_qpa_p.h
+++ b/src/gui/kernel/qeventdispatcher_glib_qpa_p.h
@@ -68,8 +68,6 @@ class QPAEventDispatcherGlib : public QEventDispatcherGlib
public:
explicit QPAEventDispatcherGlib(QObject *parent = 0);
~QPAEventDispatcherGlib();
-
- bool processEvents(QEventLoop::ProcessEventsFlags flags);
};
struct GUserEventSource;
diff --git a/src/gui/kernel/qeventdispatcher_qpa.cpp b/src/gui/kernel/qeventdispatcher_qpa.cpp
index d769b229c0..b3f41bf2c4 100644
--- a/src/gui/kernel/qeventdispatcher_qpa.cpp
+++ b/src/gui/kernel/qeventdispatcher_qpa.cpp
@@ -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
diff --git a/src/gui/kernel/qeventdispatcher_qpa_p.h b/src/gui/kernel/qeventdispatcher_qpa_p.h
index c4a222168e..f1eab6d927 100644
--- a/src/gui/kernel/qeventdispatcher_qpa_p.h
+++ b/src/gui/kernel/qeventdispatcher_qpa_p.h
@@ -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
index a79b03eee4..0000000000
--- a/src/gui/kernel/qplatformeventloopintegration_qpa.cpp
+++ /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
index 16a7cfdc6c..0000000000
--- a/src/gui/kernel/qplatformeventloopintegration_qpa.h
+++ /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
diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp
index 7dadf70879..19bac35736 100644
--- a/src/gui/kernel/qplatformintegration_qpa.cpp
+++ b/src/gui/kernel/qplatformintegration_qpa.cpp
@@ -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.
diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h
index 1a96d84a5e..053605b8ac 100644
--- a/src/gui/kernel/qplatformintegration_qpa.h
+++ b/src/gui/kernel/qplatformintegration_qpa.h
@@ -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;
diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h
index 216ab7e359..d44d344bc5 100644
--- a/src/tools/uic/qclass_lib_map.h
+++ b/src/tools/uic/qclass_lib_map.h
@@ -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)