tst_QComboBox: fix memleaks in setItemDelegate()/task253944_itemDelegateIsReset()
QItemDelegates are owned by neither the QComboBox directly, nor the QComboBox::view(), upon a mere setItemDelegate() (the docs of this function is pretty clear about that). Since the objects didn't have a QObject parent, either, they were leaked. To fix, give it the comboBox as a parent. Amends the start of the public history. Pick-to: 6.8 6.5 5.15 Change-Id: Ic8bc2603072070b458bd79a6129af6c76811f8ec Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit fda3526f9c6c34f509ebaba67a27e5c32235d7e9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
5e3db40ba3
commit
c818392a59
@ -2662,7 +2662,7 @@ void tst_QComboBox::noScrollbar()
|
||||
void tst_QComboBox::setItemDelegate()
|
||||
{
|
||||
QComboBox comboBox;
|
||||
QStyledItemDelegate *itemDelegate = new QStyledItemDelegate;
|
||||
QStyledItemDelegate *itemDelegate = new QStyledItemDelegate(&comboBox);
|
||||
comboBox.setItemDelegate(itemDelegate);
|
||||
// the cast is a workaround for the XLC and Metrowerks compilers
|
||||
QCOMPARE(static_cast<QStyledItemDelegate *>(comboBox.itemDelegate()), itemDelegate);
|
||||
@ -2671,7 +2671,7 @@ void tst_QComboBox::setItemDelegate()
|
||||
void tst_QComboBox::task253944_itemDelegateIsReset()
|
||||
{
|
||||
QComboBox comboBox;
|
||||
QStyledItemDelegate *itemDelegate = new QStyledItemDelegate;
|
||||
QStyledItemDelegate *itemDelegate = new QStyledItemDelegate(&comboBox);
|
||||
comboBox.setItemDelegate(itemDelegate);
|
||||
|
||||
// the casts are workarounds for the XLC and Metrowerks compilers
|
||||
|
Loading…
x
Reference in New Issue
Block a user