From 27279e01d2794bba8c69db4b987c3351a2daa619 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 31 Mar 2025 21:27:43 +0200 Subject: [PATCH] tst_QComboBox: fix memleaks in task_QTBUG_52027_mapCompleterIndex() Both the QCompleter and the QSortFilterProxy objects are not owned by the QComboBox merely by setting them as completer and model. Having no other QObject parents, and having being allocated on the heap, they were leaked. To fix, give them the combo-box as QObject parent. Amends 8b6d6d4832ea8ed5f9857d5ddf06408ee9d0b4e0. Pick-to: 6.9 6.8 6.5 5.15 Change-Id: I5c3594272a5283a3fbaeb9885d315047b04f30de Reviewed-by: Volker Hilsheimer --- tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index eeaacc7794d..91c0d10b7cf 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -3582,7 +3582,7 @@ void tst_QComboBox::task_QTBUG_52027_mapCompleterIndex() cbox.setInsertPolicy(QComboBox::NoInsert); cbox.addItems(words); - QCompleter *completer = new QCompleter(altWords); + QCompleter *completer = new QCompleter(altWords, &cbox); completer->setCaseSensitivity(Qt::CaseInsensitive); cbox.setCompleter(completer); @@ -3605,7 +3605,7 @@ void tst_QComboBox::task_QTBUG_52027_mapCompleterIndex() cbox.lineEdit()->selectAll(); cbox.lineEdit()->del(); - QSortFilterProxyModel* model = new QSortFilterProxyModel(); + QSortFilterProxyModel* model = new QSortFilterProxyModel(&cbox); model->setSourceModel(cbox.model()); model->setFilterFixedString("foobar1"); completer->setModel(model);