QGestureManager: prevent double-lookup in a QHash

First lookup with value(key), second lookup with remove(key). Use
constFind() to get an iterator and use that instead.

Change-Id: Idce585ad2269be91eda0381aeb2f2d164033f71f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 99c6190bdf3906bd84ed1368a4d41abe08470f78)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Ahmad Samir 2023-08-10 21:17:30 +03:00 committed by Qt Cherry-pick Bot
parent ea9f37469e
commit 85a4749302

View File

@ -110,8 +110,10 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type)
ObjectGesture objectGesture = iter.key();
if (objectGesture.gesture == type) {
foreach (QGesture *g, iter.value()) {
if (QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g)) {
m_gestureToRecognizer.remove(g);
auto it = m_gestureToRecognizer.constFind(g);
if (it != m_gestureToRecognizer.cend() && it.value()) {
QGestureRecognizer *recognizer = it.value();
m_gestureToRecognizer.erase(it);
m_obsoleteGestures[recognizer].insert(g);
}
}