From 1e744d252370c258590ee4b28ceefa3a5db5b720 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 10 Feb 2012 13:40:20 +0200 Subject: [PATCH] Avoid crash when windows with active mouse synthesization are deleted MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/gui/kernel/qguiapplication.cpp | 6 ++++-- src/gui/kernel/qguiapplication_p.h | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index b17cf58..0e525da 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::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 3ca007f..66db843 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -201,9 +201,11 @@ public: QHash 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 window; }; QHash synthesizedMousePoints; -- 2.7.4