tst_QMenu: fix memleaks in transientParent()
QActions and QMenus can be added to several widgets, so addAction() and addMenu() don't transfer ownership of their argument. Having no (QObject) parents, the QMenu and QAction objects in this test were consequently leaked. Fix by giving them parents. Amends 493a85a9e468874471057910a61e7c54a45eee83. Pick-to: 6.8 6.5 Change-Id: I2c48a55de26c5ed487d2e42e50e0b2fbb6ddf98c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 850d352111d618539d5659e139cfae9f2124fc3c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
cd26d3470a
commit
988ae2e3a2
@ -1597,12 +1597,12 @@ void tst_QMenu::transientParent()
|
||||
window.menuBar()->setNativeMenuBar(false);
|
||||
centerOnScreen(&window);
|
||||
|
||||
QMenu *fileMenu = new QMenu("&File");
|
||||
QAction *exitAct = new QAction("Exit");
|
||||
QMenu *fileMenu = new QMenu("&File", &window);
|
||||
QAction *exitAct = new QAction("Exit", &window);
|
||||
fileMenu->addAction(exitAct);
|
||||
|
||||
QMenu *editMenu = new QMenu("&Edit");
|
||||
QAction *undoAct = new QAction("Undo");
|
||||
QMenu *editMenu = new QMenu("&Edit", &window);
|
||||
QAction *undoAct = new QAction("Undo", &window);
|
||||
editMenu->addAction(undoAct);
|
||||
|
||||
QMenuBar *menuBar = new QMenuBar;
|
||||
|
Loading…
x
Reference in New Issue
Block a user