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>
bb10
Laszlo Agocs 2012-02-10 13:40:20 +02:00 committed by Qt by Nokia
parent 19a39a4ea2
commit 1e744d2523
2 changed files with 7 additions and 3 deletions

View File

@ -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(),

View File

@ -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;