summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qeventdispatcher_glib_lite.cpp2
-rw-r--r--src/gui/kernel/qeventdispatcher_lite.cpp2
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp12
-rw-r--r--src/gui/kernel/qwindowsysteminterface.h8
4 files changed, 21 insertions, 3 deletions
diff --git a/src/gui/kernel/qeventdispatcher_glib_lite.cpp b/src/gui/kernel/qeventdispatcher_glib_lite.cpp
index 0cfea8a..744925c 100644
--- a/src/gui/kernel/qeventdispatcher_glib_lite.cpp
+++ b/src/gui/kernel/qeventdispatcher_glib_lite.cpp
@@ -79,6 +79,8 @@ static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer)
QWindowSystemInterface::UserEvent * event;
while (QWindowSystemInterfacePrivate::userEventsQueued()) {
event = QWindowSystemInterfacePrivate::getUserEvent();
+ if (!event)
+ break;
// send through event filter
if (source->q->filterEvent(event)) {
diff --git a/src/gui/kernel/qeventdispatcher_lite.cpp b/src/gui/kernel/qeventdispatcher_lite.cpp
index d500ad6..5b99a2f 100644
--- a/src/gui/kernel/qeventdispatcher_lite.cpp
+++ b/src/gui/kernel/qeventdispatcher_lite.cpp
@@ -89,6 +89,8 @@ bool QEventDispatcherLite::processEvents(QEventLoop::ProcessEventsFlags flags)
&& QWindowSystemInterfacePrivate::userEventsQueued() > 0) {
// process a pending user input event
event = QWindowSystemInterfacePrivate::getUserEvent();
+ if (!event)
+ break;
} else {
break;
}
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index d7b5eef..05ca3d3 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -52,6 +52,7 @@ QTime QWindowSystemInterface::eventTime;
//
QList<QWindowSystemInterface::UserEvent *> QWindowSystemInterfacePrivate::userEventQueue;
+QMutex QWindowSystemInterfacePrivate::queueMutex;
extern QPointer<QWidget> qt_last_mouse_receiver;
/*!
@@ -109,4 +110,15 @@ void QWindowSystemInterface::handleWheelEvent(QWidget *tlw, ulong timestamp, con
QWindowSystemInterfacePrivate::queueUserEvent(e);
}
+QWindowSystemInterface::UserEvent * QWindowSystemInterfacePrivate::getUserEvent()
+{
+ queueMutex.lock();
+ QWindowSystemInterface::UserEvent *ret;
+ if (userEventQueue.isEmpty())
+ ret = 0;
+ else
+ ret = userEventQueue.takeFirst();
+ queueMutex.unlock();
+ return ret;
+}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
index 70b2830..d9bfc70 100644
--- a/src/gui/kernel/qwindowsysteminterface.h
+++ b/src/gui/kernel/qwindowsysteminterface.h
@@ -46,6 +46,7 @@
#include <QtCore/QEvent>
#include <QtGui/QWidget>
#include <QtCore/QWeakPointer>
+#include <QtCore/QMutex>
QT_BEGIN_HEADER
@@ -128,10 +129,11 @@ private:
class QWindowSystemInterfacePrivate {
public:
static QList<QWindowSystemInterface::UserEvent *> userEventQueue;
+ static QMutex queueMutex;
- static int userEventsQueued() { return userEventQueue.count(); }
- static QWindowSystemInterface::UserEvent * getUserEvent() { return userEventQueue.takeFirst(); }
- static void queueUserEvent(QWindowSystemInterface::UserEvent *ev) { userEventQueue.append(ev); }
+ static int userEventsQueued() { queueMutex.lock(); int ret = userEventQueue.count(); queueMutex.unlock(); return ret; }
+ static QWindowSystemInterface::UserEvent * getUserEvent();
+ static void queueUserEvent(QWindowSystemInterface::UserEvent *ev) { queueMutex.lock(); userEventQueue.append(ev); queueMutex.unlock(); }
};
QT_END_NAMESPACE