From 73d2a7d29b8a35ac63b7fefa42e1869a3388750c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 31 Mar 2025 21:23:32 +0200 Subject: [PATCH] tst_QComboBox: fix memleak in task190205_setModelAdjustToContents() A QComboBox does not own the model set on it, because models can be in many views at once. So the QStringListModel, allocated on the heap without a QObject parent was leaked. Fix by giving the model the combo-box as QObject parent. Amends the start of the public history. Pick-to: 6.8 6.5 5.15 Change-Id: Idd9057c8f796937d9d3c5c4ef99b329124d2192d Reviewed-by: Axel Spoerl (cherry picked from commit c41592c900257177849758ef31212a83fc813be5) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 5b452a7a1b0..eeaacc7794d 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -2471,7 +2471,7 @@ void tst_QComboBox::task190205_setModelAdjustToContents() //wait needed in order to get the combo initial size QTRY_VERIFY(box.isVisible()); - box.setModel(new QStringListModel(finalContent)); + box.setModel(new QStringListModel(finalContent, &box)); QComboBox correctBox; setFrameless(&correctBox);