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.