Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.6
-
None
-
Windows, Linux, Mac OS
-
Ic67eee79b5c6cceb2a3db3276a03f873f9550332
Description
1) A QMenuBar is parented to a widget in a hierarchy (at least 3 levels: MainWindow<-QWidget<-QWidget<-QWidget<-QMenuBar) that only the topmost parent(the main window in this case) can be a window.
2) Reparent the child of the main window to a new window (New window<-QWidget<-QWidget<-QWidget<-QMenuBar)
3) Reparent the menuBar (can be as simple as parenting it to nullptr, then reparenting it to it's original parent), but stay at the same parenting level or lower as it currently is
4) Reparent the hierarchy to another window (MainWindow<-QWidget<-QWidget<-QWidget<-QMenuBar)
5) Delete the ancien parent window
6) Do the same as step 3, the application will crash due to a segfault
What happens is that during the reparenting process of a QMenuBar, it will install two event filters, one on its parent and one on its parent's window. However, reparenting a multi-level hierarchy will not send a parent changed event to the menu bar (thus creating a discrepency between the menu bar current window and its old one). A side effect of this is that QAction events will no longer be relayed to the menu bar, reparenting the menu bar does not seem to fix this. If before re-parenting a menu bar's old window is deleted, it will access invalid memory when reparented.
Attachments
For Gerrit Dashboard: QTBUG-53205 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
158624,17 | QMenuBar: nested parenting fix | 5.6 | qt/qtbase | Status: MERGED | +2 | 0 |