diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-03-27 07:51:28 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-03-27 07:51:28 +0100 |
commit | d3ef4859e0a2813f6f9d53185511d494d75c49bd (patch) | |
tree | e755560292a704ecf248979e4c6ee9b682d91912 /sources/pyside2/PySide2 | |
parent | 9b49a68fa8f507c35fec2de5d1ec9b26c3c84463 (diff) | |
parent | d343dc28ec6b9c6f8dca4b9b678b827ab2efb2f7 (diff) |
Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I6f4621d935f74fe7ecdbaf588a05523dd44712ce
Diffstat (limited to 'sources/pyside2/PySide2')
-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)); |