Merge lp:~aacid/ubuntu-ui-toolkit/touchRegistryUnity8Fixes into lp:ubuntu-ui-toolkit/staging

Proposed by Albert Astals Cid
Status: Merged
Approved by: Timo Jyrinki
Approved revision: 1909
Merged at revision: 1939
Proposed branch: lp:~aacid/ubuntu-ui-toolkit/touchRegistryUnity8Fixes
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 122 lines (+70/-6)
2 files modified
src/Ubuntu/UbuntuGestures/touchregistry.cpp (+12/-6)
tests/unit_x11/tst_touchregistry/tst_TouchRegistry.cpp (+58/-0)
To merge this branch: bzr merge lp:~aacid/ubuntu-ui-toolkit/touchRegistryUnity8Fixes
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Zsombor Egri Approve
Michael Terry Pending
Nick Dedekind Pending
Review via email: mp+290024@code.launchpad.net

This proposal supersedes a proposal from 2016-03-24.

Commit message

Fix Bug caused by candidates getting removed during ownership resolution

Ported from unity8 codebase

To post a comment you must log in.
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

Good to go from my side. Nice test!

review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Re-topapproving MP that was previously topapproved but prevented from going in by CI.

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/UbuntuGestures/touchregistry.cpp'
2--- src/Ubuntu/UbuntuGestures/touchregistry.cpp 2015-11-27 06:16:11 +0000
3+++ src/Ubuntu/UbuntuGestures/touchregistry.cpp 2016-03-24 11:28:14 +0000
4@@ -507,14 +507,20 @@
5 UG_DEBUG << "sending TouchOwnershipEvent(id =" << id
6 << " gained) to candidate" << candidates[0].item;
7
8+ // need to take a copy of the item list in case
9+ // we call back in to remove candidate during the lost ownership event.
10+ QList<QPointer<QQuickItem>> items;
11+ Q_FOREACH(const CandidateInfo& info, candidates) {
12+ items << info.item;
13+ }
14+
15 TouchOwnershipEvent gainedOwnershipEvent(id, true /*gained*/);
16- QCoreApplication::sendEvent(candidates[0].item, &gainedOwnershipEvent);
17-
18+ QCoreApplication::sendEvent(items[0], &gainedOwnershipEvent);
19
20 TouchOwnershipEvent lostOwnershipEvent(id, false /*gained*/);
21- for (int i = 1; i < candidates.count(); ++i) {
22- UG_DEBUG << "sending TouchWonershipEvent(id =" << id << " lost) to candidate"
23- << candidates[i].item;
24- QCoreApplication::sendEvent(candidates[i].item, &lostOwnershipEvent);
25+ for (int i = 1; i < items.count(); ++i) {
26+ UG_DEBUG << "sending TouchOwnershipEvent(id =" << id << " lost) to candidate"
27+ << items[i];
28+ QCoreApplication::sendEvent(items[i], &lostOwnershipEvent);
29 }
30 }
31
32=== modified file 'tests/unit_x11/tst_touchregistry/tst_TouchRegistry.cpp'
33--- tests/unit_x11/tst_touchregistry/tst_TouchRegistry.cpp 2016-03-16 17:20:49 +0000
34+++ tests/unit_x11/tst_touchregistry/tst_TouchRegistry.cpp 2016-03-24 11:28:14 +0000
35@@ -42,6 +42,10 @@
36 QSet<int> ownedTouches;
37 QSet<int> lostTouches;
38 QList<TouchMemento> unownedTouchEvents;
39+
40+Q_SIGNALS:
41+ void gainedOwnership();
42+ void lostOwnership();
43 };
44
45 class tst_TouchRegistry : public QObject
46@@ -68,6 +72,7 @@
47 void removeOldUndecidedCandidates();
48 void interimOwnerWontGetUnownedTouchEvents();
49 void candidateVanishes();
50+ void candicateOwnershipReentrace();
51
52 private:
53 TouchRegistry *touchRegistry;
54@@ -864,6 +869,57 @@
55 QVERIFY(mainCandidate.ownedTouches.contains(0));
56 }
57
58+/*
59+ Regression test for canidate reentrance
60+
61+ Bug caused by candidates getting removed during ownership resolution
62+ */
63+void tst_TouchRegistry::candicateOwnershipReentrace()
64+{
65+ DummyCandidate mainCandidate;
66+ DummyCandidate candicate2;
67+ DummyCandidate candicate3;
68+
69+ {
70+ QList<QTouchEvent::TouchPoint> touchPoints;
71+ touchPoints.append(QTouchEvent::TouchPoint(0));
72+ touchPoints[0].setState(Qt::TouchPointPressed);
73+ QTouchEvent touchEvent(QEvent::TouchBegin,
74+ 0 /* device */,
75+ Qt::NoModifier,
76+ Qt::TouchPointPressed,
77+ touchPoints);
78+ touchRegistry->update(&touchEvent);
79+ }
80+
81+ // Re-entrance!
82+ connect(&candicate2, &DummyCandidate::lostOwnership, this, [&]() {
83+ touchRegistry->removeCandidateOwnerForTouch(0, &candicate2);
84+ });
85+
86+ touchRegistry->addCandidateOwnerForTouch(0, &mainCandidate);
87+ touchRegistry->addCandidateOwnerForTouch(0, &candicate2);
88+ touchRegistry->addCandidateOwnerForTouch(0, &candicate3);
89+
90+ {
91+ QList<QTouchEvent::TouchPoint> touchPoints;
92+ touchPoints.append(QTouchEvent::TouchPoint(0));
93+ touchPoints[0].setState(Qt::TouchPointMoved);
94+ QTouchEvent touchEvent(QEvent::TouchUpdate,
95+ 0 /* device */,
96+ Qt::NoModifier,
97+ Qt::TouchPointMoved,
98+ touchPoints);
99+ touchRegistry->update(&touchEvent);
100+ }
101+
102+ touchRegistry->requestTouchOwnership(0, &mainCandidate);
103+
104+ QCOMPARE(mainCandidate.ownedTouches.count(), 1);
105+ QCOMPARE(candicate2.lostTouches.count(), 1);
106+ QCOMPARE(candicate3.lostTouches.count(), 1);
107+}
108+
109 ////////////// TouchMemento //////////
110
111 TouchMemento::TouchMemento(const QTouchEvent *touchEvent)
112@@ -897,8 +953,10 @@
113
114 if (touchOwnershipEvent->gained()) {
115 ownedTouches.insert(touchOwnershipEvent->touchId());
116+ Q_EMIT gainedOwnership();
117 } else {
118 lostTouches.insert(touchOwnershipEvent->touchId());
119+ Q_EMIT lostOwnership();
120 }
121 return true;
122 } else if (e->type() == UnownedTouchEvent::unownedTouchEventType()) {

Subscribers

People subscribed via source and target branches