QMenuBar: Mark items as dirty when switching away from native menu bar
QMenuBarPrivate::updateGeometries() returns early if the native menu bar is in use, skipping the call to calcActionRects, so the action rects are not in sync with the actions in this mode. When switching to non-native menu bars, we would then crash in QMenuBar::minimumSizeHint() because we're iterating the action rects assuming the match the actions. To fix this we need to ensure the action rects are computed by our call to updateGeometries() in setNativeMenuBar(), which we can do by explicitly marking the items as dirty. Note that it's currently not possible to switch back to the native menu bar, as the native menu bar is populated in QMenuBar::actionEvent via QEvent::ActionAdded, and we're not doing anything to re-add these actions once we've recreated the native menu bar. Fixes: QTBUG-102107 Pick-to: 6.5 6.4 6.2 Change-Id: I7cf2b25539da633727693f5894ea22ea0d0d9aa5 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
5947c07717
commit
5a9fbae0ba
@ -1772,6 +1772,7 @@ void QMenuBar::setNativeMenuBar(bool nativeMenuBar)
|
||||
if (!nativeMenuBar) {
|
||||
delete d->platformMenuBar;
|
||||
d->platformMenuBar = nullptr;
|
||||
d->itemsDirty = true;
|
||||
} else {
|
||||
if (!d->platformMenuBar)
|
||||
d->platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
|
||||
|
Loading…
x
Reference in New Issue
Block a user