From: Laszlo Agocs Date: Fri, 10 Feb 2012 11:40:20 +0000 (+0200) Subject: Avoid crash when windows with active mouse synthesization are deleted X-Git-Tag: qt-v5.0.0-alpha1~1152 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1e744d252370c258590ee4b28ceefa3a5db5b720;p=profile%2Fivi%2Fqtbase.git 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 --- 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;