Fix a crash in tst_QTouchEvent::deleteInRawEventTranslation().

The test deletes a widget in QEvent::TouchBegin.

This is part of a series of patches to revive the test; it is currently
not run since tests/auto/gui/kernel/qtouchevent/qtouchevent.pro
is missing CONFIG += testcase.

Task-number: QTBUG-46266
Change-Id: I65c0a431ff1807133438764dd8b3c16bb9cb6743
Reviewed-by: Caroline Chao <caroline.chao@theqtcompany.com>
This commit is contained in:
Friedemann Kleint 2015-05-21 15:45:41 +02:00
parent d8bfd812c3
commit 6794319bbd

View File

@ -4377,7 +4377,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
QHash<QWidget *, StatesAndTouchPoints>::ConstIterator it = widgetsNeedingEvents.constBegin();
const QHash<QWidget *, StatesAndTouchPoints>::ConstIterator end = widgetsNeedingEvents.constEnd();
for (; it != end; ++it) {
QWidget *widget = it.key();
const QPointer<QWidget> widget = it.key();
if (!QApplicationPrivate::tryModalHelper(widget, 0))
continue;
@ -4417,7 +4417,8 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
// has been implicitly accepted and continue to send touch events
if (QApplication::sendSpontaneousEvent(widget, &touchEvent) && touchEvent.isAccepted()) {
accepted = true;
widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent);
if (!widget.isNull())
widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent);
}
break;
}