Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
4.6.2
-
None
-
Tested on 10.6.
Description
To see the issue in the following code, build and click on the test2 menu item.
note that moving the delete of the mAppSpec action up to the top of the
create() method will workaround the issue in 4.7, but causes a crash in 4.6
//main.cpp #include <QApplication> #include <QMainWindow> #include <QMenuBar> #include <QAction> class test: public QMainWindow { Q_OBJECT; public: test() :QMainWindow() { tt = new QMenu(this); mTest = new QAction(this) ; mAppSpec = new QAction(this) ; create(); } signals: void test1(); public slots: void create() { // delete mAppSpec; delete tt; QMenuBar *pMenuBar = menuBar(); tt = new QMenu(this); tt->setTitle("Test"); delete mTest; mTest = new QAction(this); mTest->setText("test2"); connect (mTest, SIGNAL(triggered()), this, SLOT(onClicked())); tt->addAction(mTest); delete mAppSpec; mAppSpec = new QAction(this); mAppSpec->setText("App Spec"); mAppSpec->setMenuRole(QAction::ApplicationSpecificRole); connect (mAppSpec, SIGNAL(triggered()), this, SLOT(onAppSpec())); tt->addAction(mAppSpec); pMenuBar->addMenu(tt); } void onClicked() { create(); } void onAppSpec() { qDebug("app spec"); } private: QMenu *tt; QAction *mTest; QAction *mAppSpec; }; int main(int argc, char *argv[]) { QApplication app (argc, argv); test *mw = new test; mw->show(); return app.exec(); } #include "main.moc"