QScroller: Fix crash when multiple scrollers are registered

Ensure the scroller cannot be added multiple times to the
list of active scrollers. Patch as contributed on bug report.
Amends 8b8e53f726.

Change-Id: Ic4e7d3e981f36e330dfd28d468288c5ef4b74a4c
Fixes: QTBUG-72244
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
bb10
Friedemann Kleint 2018-12-07 09:25:02 +01:00
parent 90c1107698
commit e27f52a098
1 changed files with 5 additions and 3 deletions

View File

@ -1725,10 +1725,12 @@ void QScrollerPrivate::setState(QScroller::State newstate)
sendEvent(target, &se);
firstScroll = true;
}
if (state == QScroller::Dragging || state == QScroller::Scrolling)
qt_activeScrollers()->push_back(q);
else
if (state == QScroller::Dragging || state == QScroller::Scrolling) {
if (!qt_activeScrollers()->contains(q))
qt_activeScrollers()->push_back(q);
} else {
qt_activeScrollers()->removeOne(q);
}
emit q->stateChanged(state);
}