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.

Pick-to: 6.6 6.5
Change-Id: Idce585ad2269be91eda0381aeb2f2d164033f71f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Ahmad Samir 2023-08-10 21:17:30 +03:00
parent 814b7fd3a8
commit 99c6190bdf
1 changed files with 4 additions and 2 deletions

View File

@ -112,8 +112,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);
}
}