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 <axel.spoerl@qt.io>
(cherry picked from commit c41592c900257177849758ef31212a83fc813be5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2025-03-31 21:23:32 +02:00 committed by Qt Cherry-pick Bot
parent c818392a59
commit 73d2a7d29b

View File

@ -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);