summaryrefslogtreecommitdiffstats
path: root/tests/auto/other
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-08-14 03:07:18 +0300
committerAhmad Samir <a.samirh78@gmail.com>2023-10-11 23:06:20 +0300
commite48e2b3b4a65dadc0cc013bcc5132db8c530a3f3 (patch)
tree68b1f8003ea54a5a2ccd5a50e06b9aa95754fcf6 /tests/auto/other
parent29af4b1833e76ae1eeeca6ed9f0b9f8a9cb8c03f (diff)
tst_Gestures: compile with QT_NO_FOREACH [1/2]
GestureWidget::ignoredGestures QSet: - elements are inserted in the container in a top-level test function, then a CustomEvent is constructed and sendCustomGesture() is called, which sends the events, invoking the GestureWidget::event() overload, the latter iterates over the container, thus the container isn't changed while it's being iterated over, because the code can't recurse into the top-level test function and that's where the container is modified later on (by inserting or by calling widget.reset() which clears the container) - the loop body doesn't change the container So use ranged-for and std::as_const. The same logic applies to the GestureItem::ignoredGestures QSet. Task-number: QTBUG-115839 Change-Id: Icf95e90a8af5aa7e947035704121557494afc326 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/other')
-rw-r--r--tests/auto/other/gestures/tst_gestures.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp
index 42a61955b6..be40887be6 100644
--- a/tests/auto/other/gestures/tst_gestures.cpp
+++ b/tests/auto/other/gestures/tst_gestures.cpp
@@ -210,7 +210,7 @@ protected:
QGestureEvent *e = static_cast<QGestureEvent*>(event);
++gestureEventsReceived;
eventsPtr = &events;
- foreach(Qt::GestureType type, ignoredGestures)
+ for (Qt::GestureType type : std::as_const(ignoredGestures))
e->ignore(e->gesture(type));
} else if (event->type() == QEvent::GestureOverride) {
++gestureOverrideEventsReceived;
@@ -744,7 +744,7 @@ public:
++gestureEventsReceived;
eventsPtr = &events;
QGestureEvent *e = static_cast<QGestureEvent *>(event);
- foreach(Qt::GestureType type, ignoredGestures)
+ for (Qt::GestureType type : std::as_const(ignoredGestures))
e->ignore(e->gesture(type));
foreach(QGesture *g, e->gestures()) {
switch (g->state()) {