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.8 6.5 5.15 Change-Id: I5c3594272a5283a3fbaeb9885d315047b04f30de Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 27279e01d2794bba8c69db4b987c3351a2daa619) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
73d2a7d29b
commit
fee3a39fdc
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user