diff options
author | Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com> | 2015-05-19 11:20:12 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com> | 2015-05-22 09:59:41 +0000 |
commit | b8db3a1c6036e6d8ab68b5f1c01a00c289a67ab8 (patch) | |
tree | 97301552b6bc2229bbfb94440c2d08681da6fca6 /tests | |
parent | eb2ea7098512bdc241b7fdabf5c21c229d56fc07 (diff) |
qquickwindow: ensure we delete the correct delayed touch event after delivery
Delivering a delayed touch event from QQuickWindow can cause the event loop
to recurse (e.g if it starts a drag'n'drop). This again can cause new touch
events to be delivered to QQuickWindow, and new delayed touch events to be
stored.
This results in the following:
(1) Receive new touch press event in QQuickWindow, and set
delayedTouch to be a copy of it
(2) Deliver delayedTouch to items. This can cause an event loop
recursion.
(3) While inside the recursion, QQuickWindow receives another new
touch press event. We then redeliver and delete the current
delayedTouch event created in (1), and set delayedTouch to be
a copy of the new event.
(4) Later we return back from (2), and try to access
delayedTouch (or actually a reference to the touchpoints inside
it, qquickwindow.cpp:1958). Since the event was deleted in (3), we
have a crash.
This patch will ensure that we set delayedTouch to 0 before delivering
it (so it cannot be redelivered), and that we safely delete it afterwards
when it goes out of scope. By converting delayedTouch to a QScopedPointer
we also ensure that the event is not leaked upon destruction.
Task-number: QTBUG-45877
Change-Id: Ic372a39a0eb127abfd12cec2d51b3743ad83194d
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/shared/viewtestutil.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index 24e565012e..5b9111d448 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -350,9 +350,7 @@ namespace QQuickTouchUtils { QQuickWindowPrivate *wd = QQuickWindowPrivate::get(window); if (!wd || !wd->delayedTouch) return; - wd->reallyDeliverTouchEvent(wd->delayedTouch); - delete wd->delayedTouch; - wd->delayedTouch = 0; + wd->deliverDelayedTouchEvent(); } } |