diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index d8977a5e90e..e86b94ac4d5 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -2931,17 +2932,16 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To // Send the TouchCancel to all windows with active touches and clean up. QTouchEvent touchEvent(QEvent::TouchCancel, device, e->modifiers); touchEvent.setTimestamp(e->timestamp); - QSet windowsNeedingCancel; + QMinimalVarLengthFlatSet windowsNeedingCancel; for (auto &epd : devPriv->activePoints.values()) { if (QWindow *w = QMutableEventPoint::window(epd.eventPoint)) windowsNeedingCancel.insert(w); } - for (QSet::const_iterator winIt = windowsNeedingCancel.constBegin(), - winItEnd = windowsNeedingCancel.constEnd(); winIt != winItEnd; ++winIt) { - QGuiApplication::sendSpontaneousEvent(*winIt, &touchEvent); - } + for (QWindow *w : windowsNeedingCancel) + QGuiApplication::sendSpontaneousEvent(w, &touchEvent); + if (!self->synthesizedMousePoints.isEmpty() && !e->synthetic()) { for (QHash::const_iterator synthIt = self->synthesizedMousePoints.constBegin(), synthItEnd = self->synthesizedMousePoints.constEnd(); synthIt != synthItEnd; ++synthIt) {