diff options
author | Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2020-03-30 10:07:56 +0200 |
---|---|---|
committer | Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2020-03-30 10:07:56 +0200 |
commit | d2be09eef06241cd4c9eb7a0ca1a993dc2355f02 (patch) | |
tree | 4cd15a74c0629e76a41b30d2e02d22e998fb509d /sources/pyside2/PySide2/glue/qtwidgets.cpp | |
parent | ad73193e99fef8f5d1bcf095075596dca88949c1 (diff) | |
parent | d47fb98e443e3ac5cb18850b2551143c713917f0 (diff) |
Merge branch '5.14' into 5.14.2v5.14.2
Change-Id: I3f76bc2b1d401d901d6ac5bc74874b0894bf3df9
Diffstat (limited to 'sources/pyside2/PySide2/glue/qtwidgets.cpp')
-rw-r--r-- | sources/pyside2/PySide2/glue/qtwidgets.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sources/pyside2/PySide2/glue/qtwidgets.cpp b/sources/pyside2/PySide2/glue/qtwidgets.cpp index 1c663364c..4f9baadf1 100644 --- a/sources/pyside2/PySide2/glue/qtwidgets.cpp +++ b/sources/pyside2/PySide2/glue/qtwidgets.cpp @@ -413,7 +413,15 @@ for (auto *item : items) { // @snippet qtreewidget-clear QTreeWidgetItem *rootItem = %CPPSELF.invisibleRootItem(); Shiboken::BindingManager &bm = Shiboken::BindingManager::instance(); -for (int i = 0, i_count = rootItem->childCount(); i < i_count; ++i) { + +// PYSIDE-1251: +// Since some objects can be created with a parent and without +// being saved on a local variable (refcount = 1), they will be +// deleted when setting the parent to nullptr, so we change the loop +// to do this from the last child to the first, to avoid the case +// when the child(1) points to the original child(2) in case the +// first one was removed. +for (int i = rootItem->childCount() - 1; i >= 0; --i) { QTreeWidgetItem *item = rootItem->child(i); if (SbkObject *wrapper = bm.retrieveWrapper(item)) Shiboken::Object::setParent(nullptr, reinterpret_cast<PyObject *>(wrapper)); |