summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2012-02-10 13:40:20 +0200
committerQt by Nokia <qt-info@nokia.com>2012-02-10 19:39:57 +0100
commit1e744d252370c258590ee4b28ceefa3a5db5b720 (patch)
treec8c6b98a7c072ac79c3a25ced12d38201b9b00a9 /src/gui
parent19a39a4ea2f7ef7f9a1e8a54fc13240e79ccf79d (diff)
Avoid crash when windows with active mouse synthesization are deleted
Some QtQuick autotests, that apparently generate incomplete touch sequences and delete windows without finishing them, triggered a crash when handling the TouchCancel event in QGuiApplication. Change-Id: Ie725d5a16f55acc40bdc8e2c38f93daac9477f2a Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qguiapplication.cpp6
-rw-r--r--src/gui/kernel/qguiapplication_p.h4
2 files changed, 7 insertions, 3 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index b17cf5824c..0e525da151 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -975,7 +975,9 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
if (!self->synthesizedMousePoints.isEmpty() && !e->synthetic) {
for (QHash<QWindow *, SynthesizedMouseData>::const_iterator synthIt = self->synthesizedMousePoints.constBegin(),
synthItEnd = self->synthesizedMousePoints.constEnd(); synthIt != synthItEnd; ++synthIt) {
- QWindowSystemInterfacePrivate::MouseEvent fake(synthIt.key(),
+ if (!synthIt->window)
+ continue;
+ QWindowSystemInterfacePrivate::MouseEvent fake(synthIt->window.data(),
e->timestamp,
synthIt->pos,
synthIt->screenPos,
@@ -1159,7 +1161,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
if (touchPoint.id() == m_fakeMouseSourcePointId) {
if (b != Qt::NoButton)
self->synthesizedMousePoints.insert(w, SynthesizedMouseData(
- touchPoint.pos(), touchPoint.screenPos()));
+ touchPoint.pos(), touchPoint.screenPos(), w));
QWindowSystemInterfacePrivate::MouseEvent fake(w, e->timestamp,
touchPoint.pos(),
touchPoint.screenPos(),
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 3ca007fb36..66db8437e5 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -201,9 +201,11 @@ public:
QHash<ActiveTouchPointsKey, ActiveTouchPointsValue> activeTouchPoints;
QEvent::Type lastTouchType;
struct SynthesizedMouseData {
- SynthesizedMouseData(const QPointF &p, const QPointF &sp) : pos(p), screenPos(sp) { }
+ SynthesizedMouseData(const QPointF &p, const QPointF &sp, QWindow *w)
+ : pos(p), screenPos(sp), window(w) { }
QPointF pos;
QPointF screenPos;
+ QWeakPointer<QWindow> window;
};
QHash<QWindow *, SynthesizedMouseData> synthesizedMousePoints;