Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.7.0, 5.0.0
-
None
-
Windows
-
Qt 4: 00bbab0dbfde79cfc6a3dc6060d7c87763f07482 , Qt 5: 7694599ef933b306d54116723adab0d5d8651ff5
Description
Right click on the menubar or docked widget several times, the default context menu will be shown one by one. When the new menu is shown, the old one does not destroyed. This will lead to memory leak.
You can reproduce the problem with following code:
- right click on the menubar or docked widget serveral times
- then click the "dump object tree" button, you will see many menu objects in console window.
#include <QtGui> class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); private slots: void onButtonClicked(); }; MainWindow::MainWindow(QWidget *parent) { addToolBar("ToolBar"); addDockWidget(Qt::LeftDockWidgetArea, new QDockWidget("DockWidget")); QPushButton * btn = new QPushButton("dump object tree"); setCentralWidget(btn); connect(btn, SIGNAL(clicked()), SLOT(onButtonClicked())); } void MainWindow::onButtonClicked() { dumpObjectTree(); } #include "main.moc" int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
Attachments
Issue Links
- is replaced by
-
QTBUG-22817 Memory leak caused by the content menu of QLineEdit, QTextEdit, QMessageBox, ...
- Closed