diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index c20639d20e..7b270d9241 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -118,14 +118,13 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(NotificationReceiver); - (void)scrollBarStyleDidChange:(NSNotification *)notification { Q_UNUSED(notification); + + // purge destroyed scroll bars: + QMacStylePrivate::scrollBars.removeAll(QPointer()); + QEvent event(QEvent::StyleChange); - QMutableVectorIterator > it(QMacStylePrivate::scrollBars); - while (it.hasNext()) { - if (!it.next()) - it.remove(); - else - QCoreApplication::sendEvent(it.value(), &event); - } + for (const auto &o : QMacStylePrivate::scrollBars) + QCoreApplication::sendEvent(o, &event); } @end