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

Crash when deleting a QMenu as the result of triggering one of its actions

    XMLWordPrintable

Details

    • Linux/X11, Windows

    Description

      In the context of an application which manages several kinds of documents (and therefore several kinds of views), the application's main menu bar is rebuilt according to the document type of the active view.

      If triggering an action from a menu entry of document A results in the creation and display of a document B for which such a menu entry doesn't exist, then the corresponding QMenu is deleted and the application crashes in QMenuPrivate::activateAction() because the object is deleted. Crash happens at line 1445 of qmenu.cpp:

      actionAboutToTrigger = 0;
      

      because actionAboutToTrigger is an object property.

      A simple solution would be to use a guarded pointer before calling:

      activateCausedStack(causedStack, action, action_e, self);
      

      which might results in the deletion of the current object. i.e. something like:

      QPointer<QMenuPrivate> guardedPtr(this);
      activateCausedStack(causedStack, action, action_e, self);
      if (!guardedPtf)
          return;
      

      The other alternative, which consists in using deleteLater() on the QMenu object instead of directly deleting it when rebuilding the menu bar unfortunately doesn't work if for some reasons QApplication::processEvents() is called after the menu is rebuilt.

       

      Attachments

        Issue Links

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

          Activity

            People

              vhilshei Volker Hilsheimer
              gehant Sebastien Gehant
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes