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

Regression: context menu with submenu crashes on second open

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.3.0 RC1
    • Fix Version/s: 5.3.0 RC1
    • Component/s: GUI: Look'n'Feel
    • Labels:
      None
    • Environment:
      OS X 10.9, qtbase/release (ee85cdee67d164315e52a05462b03fe7091cc26d)
    • Commits:
      8605f44097a986e10c2ddaf4b4eae0b2331d98d1

      Description

      crashes on the second right click. Works with Qt 5.2.1.

      #include <QApplication>
      #include <QContextMenuEvent>
      #include <QMainWindow>
      #include <QMenu>
      
      class MainWindow : public QMainWindow
      {
      public:
        MainWindow(QWidget *parent = 0)
          : QMainWindow(parent)
        {
          submenu = new QMenu("Submenu", this);
        }
      
        virtual void contextMenuEvent(QContextMenuEvent *event)
        {
          submenu->clear();
          QAction *action = submenu->addAction("Test");
          action->setData(0); // Crash happens here second time...
      
          QMenu menu;
          menu.addMenu(submenu);
          menu.exec(event->globalPos());
        }
      
      private:
        QMenu *submenu;
      };
      
      int main (int argc, char *argv[])
      {
        QApplication app(argc, argv);
        MainWindow window;
        window.show();
        return app.exec();
      }
      

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              dedietri Gabriel de Dietrich (drgvond)
              Reporter:
              con Eike Ziller
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes