Skip to content

Commit

Permalink
QMainWindow: Clear menubar parent when new one is set
Browse files Browse the repository at this point in the history
In QMainWindow::setMenuBar(), we hide and schedule the current
menubar, if any, to be deleted later. However, it remains installed
as its whole ancestry's event filter, which could conflict with the
newly assigned menubar until the old menubar is destroyed. In our
case, we have noticed issues with the Cocoa QPA plugin.

We force uninstalling the old menubar as event filter by setting its
parent to null, pending its deletion shortly after.

This fixes BigMenuCreator's empty menubar when calling it with only
the "--new-menubar" option. It also fixes QTBUG-34160 example which
was not behaving as well as it should.

Task-number: QTBUG-34160
Change-Id: Ifefb72affad01e7b7371005442074afd6a39a5b8
Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
  • Loading branch information
Gabriel de Dietrich authored and ec1oud committed Nov 7, 2017
1 parent 7986e1e commit 5d6878f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/widgets/widgets/qmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar)
menuBar->setCornerWidget(cornerWidget, Qt::TopRightCorner);
}
oldMenuBar->hide();
oldMenuBar->setParent(nullptr);
oldMenuBar->deleteLater();
}
topLayout->setMenuBar(menuBar);
Expand Down

0 comments on commit 5d6878f

Please sign in to comment.