@@ -1,5 +1,5 @@
11/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013-2016 Canonical Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -26,9 +26,14 @@ TouchEventSequenceWrapper::TouchEventSequenceWrapper(QTest::QTouchEventSequence
2626
2727void TouchEventSequenceWrapper::commit(bool processEvents)
2828{
29+ // Item might be deleted as a consequence of this event sequence being handled
30+ // So store its window beforehand
31+ QQuickWindow *window = m_item->window();
32+
2933 m_eventSequence.commit(processEvents);
30− if (m_item->window()) {
31− QQuickWindowPrivate *wp = QQuickWindowPrivate::get(m_item->window());
34+
35+ if (window) {
36+ QQuickWindowPrivate *wp = QQuickWindowPrivate::get(window);
3237 wp->flushDelayedTouchEvent();
3338 }
3439}