summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <[email protected]>2023-03-10 14:30:43 +0100
committerQt Cherry-pick Bot <[email protected]>2023-03-13 16:29:11 +0000
commit80eba4bb944cc08651ecb01553492786ec3f4ec1 (patch)
tree23852e4108036e5a46831ccc2700add78a0dee02
parentdd8c369f83ee96a8f89fbb29d17c4c844fb4f814 (diff)
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 Change-Id: I7cf2b25539da633727693f5894ea22ea0d0d9aa5 Reviewed-by: Richard Moe Gustavsen <[email protected]> (cherry picked from commit 5a9fbae0ba12622e12287aa1c89f4f3d58379ecc) Reviewed-by: Qt Cherry-pick Bot <[email protected]>
-rw-r--r--src/widgets/widgets/qmenubar.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 01ad37cab0f..bc690029e92 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -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();