Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-53205

Crash in QMenuBar while reparenting nested QWidgets to different windows

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.6.2, 5.7.0
    • 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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            badsingleton Felix Bourbonnais
            badsingleton Felix Bourbonnais
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes