vcl/qt5/QtMenu.cxx | 6 ++++++ 1 file changed, 6 insertions(+) New commits: commit f751417b77e6573a0c639778e76ec943449f4573 Author: Jan-Marek Glogowski <glo...@fbihome.de> AuthorDate: Mon Apr 11 17:56:16 2022 +0200 Commit: Jan-Marek Glogowski <glo...@fbihome.de> CommitDate: Tue Apr 12 12:24:29 2022 +0200
tdf#148491 Qt reconnect the QMenuBar close button When the QMenuBar of a QMainWindow is replaced, an existing corner widget is preserved / transferred, but its connections are still severed; a bit unexpected... The documentation for QMenuBar::setCornerWidget is not really clear what is happening, but the code has this nice comment: "// Reparent corner widgets before we delete the old menu". At least there is no need to explicitly delete the button. Still we must reconnect an existing button on each SetFrame. Regression from commit 9c4ef8ce3183e27ca174475cf4a8d15cc0368f60 ("tdf#145954 Qt unshare QMenubar usage"). Change-Id: I13c31734e665b78231a08cd76ca6305122e08879 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132836 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx index 50cb1d057431..fd38a0380000 100644 --- a/vcl/qt5/QtMenu.cxx +++ b/vcl/qt5/QtMenu.cxx @@ -429,6 +429,10 @@ void QtMenu::SetFrame(const SalFrame* pFrame) mpQMenuBar = new QMenuBar(); pMainWindow->setMenuBar(mpQMenuBar); + + QPushButton* pButton = static_cast<QPushButton*>(mpQMenuBar->cornerWidget(Qt::TopRightCorner)); + if (pButton) + connect(pButton, &QPushButton::clicked, this, &QtMenu::slotCloseDocument); mpQMenu = nullptr; DoFullMenuUpdate(mpVCLMenu); @@ -647,6 +651,8 @@ void QtMenu::ShowCloseButton(bool bShow) return; QPushButton* pButton = static_cast<QPushButton*>(mpQMenuBar->cornerWidget(Qt::TopRightCorner)); + if (!pButton && !bShow) + return; if (!pButton) { QIcon aIcon;