Fix UB in QGraphicsScene::wheelEvent()
operator--() would iterate before begin() if the list was empty. This is UB, and will crash in Qt 6, where begin()/end() can return an iterator pointing to a nullptr if the list is empty. Change-Id: I39c3a8ebb09fcad75d42019b02426ac5ac05eed9 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>bb10
parent
d4ff606941
commit
f98fe1ba41
|
|
@ -4101,7 +4101,8 @@ void QGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *wheelEvent)
|
|||
// Remove all popups after the one found, or all or them if no popup is under the mouse.
|
||||
// Then continue with the event.
|
||||
QList<QGraphicsWidget *>::const_iterator iter = d->popupWidgets.constEnd();
|
||||
while (--iter >= d->popupWidgets.constBegin() && !wheelCandidates.isEmpty()) {
|
||||
while (iter > d->popupWidgets.constBegin() && !wheelCandidates.isEmpty()) {
|
||||
--iter;
|
||||
if (wheelCandidates.first() == *iter || (*iter)->isAncestorOf(wheelCandidates.first()))
|
||||
break;
|
||||
d->removePopup(*iter);
|
||||
|
|
|
|||
Loading…
Reference in New Issue