summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKirill Burtsev <kirill.burtsev@qt.io>2020-10-28 14:26:05 +0100
committerKirill Burtsev <kirill.burtsev@qt.io>2020-11-18 16:22:21 +0100
commita6a9a65e3ac7d1cd255cbe74df7070c091941216 (patch)
tree846cb0ab4fd2d023152531b45b27a3f3b056f375
parentfe9e71201590db3eac0d4be31f8a60887dfe4ef8 (diff)
Fix rare duplicate ids forming in touch point id's mapping
QTouchEvent may contain touch point release and press simultaneously in this particular order. Hence if mapping for released point is deleted before id is chosen for pressed one, output transformed list may contain points with same ids. Since new touch points delivered before released one, this will lead to assert in chromium about duplicate ids. Change-Id: I209d7d8c752c7bd74d2580ef65478c92e54cb099 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/core/render_widget_host_view_qt.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 525e9924e..f8e20d188 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -1251,6 +1251,7 @@ void RenderWidgetHostViewQt::processMotionEvent(const ui::MotionEvent &motionEve
QList<QTouchEvent::TouchPoint> RenderWidgetHostViewQt::mapTouchPointIds(const QList<QTouchEvent::TouchPoint> &inputPoints)
{
+ QList<int> idsToRemove;
QList<QTouchEvent::TouchPoint> outputPoints = inputPoints;
for (int i = 0; i < outputPoints.size(); ++i) {
QTouchEvent::TouchPoint &point = outputPoints[i];
@@ -1262,9 +1263,14 @@ QList<QTouchEvent::TouchPoint> RenderWidgetHostViewQt::mapTouchPointIds(const QL
point.setId(it.value());
if (point.state() == Qt::TouchPointReleased)
- m_touchIdMapping.remove(qtId);
+ idsToRemove.append(qtId);
}
+ for (int qtId : qAsConst(idsToRemove))
+ m_touchIdMapping.remove(qtId);
+
+ Q_ASSERT(outputPoints.size() == std::accumulate(outputPoints.cbegin(), outputPoints.cend(), QSet<int>(),
+ [] (QSet<int> s, const QTouchEvent::TouchPoint &p) { s.insert(p.id()); return s; }).size());
return outputPoints;
}