QGestureManager: fix expensive iteration over QHash::keys()

... with iteration over the hash itself.

gesturesByType is a local variable, so there's no way
functions called in the loop can modify it.

Change-Id: I5971c404f4ae8473d4926b68eb7a9c60801f208d
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
bb10
Marc Mutz 2015-06-21 12:37:37 +02:00
parent 8a25f888e9
commit 3045ac99f2
1 changed files with 3 additions and 3 deletions

View File

@ -569,13 +569,13 @@ void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures,
}
// for each gesture type
foreach (Qt::GestureType type, gestureByTypes.keys()) {
QHash<QWidget *, QGesture *> gestures = gestureByTypes.value(type);
for (GestureByTypes::const_iterator git = gestureByTypes.cbegin(), gend = gestureByTypes.cend(); git != gend; ++git) {
const QHash<QWidget *, QGesture *> &gestures = git.value();
foreach (QWidget *widget, gestures.keys()) {
QWidget *w = widget->parentWidget();
while (w) {
QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator it
= w->d_func()->gestureContext.constFind(type);
= w->d_func()->gestureContext.constFind(git.key());
if (it != w->d_func()->gestureContext.constEnd()) {
// i.e. 'w' listens to gesture 'type'
if (!(it.value() & Qt::DontStartGestureOnChildren) && w != widget) {