aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/PySide2/QtWidgets
diff options
context:
space:
mode:
authorCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2018-01-26 09:47:48 +0100
committerSimo Fält <simo.falt@qt.io>2018-02-02 10:21:23 +0000
commita18e81dd1311811eb1227cf46d253ae647a9fbdd (patch)
treea5a948f28441163605da26a04b0e36af55980fb2 /sources/pyside2/PySide2/QtWidgets
parent27e24a733b8a65623683b00c0764ef00d05fa397 (diff)
Fix QTabWidget.clear to avoid double obj removal
Replacing shiboken call setParent with releaseOwnership so Python will not delete the underlying C++ object. A test case is provided to check that the error is not happening. Task-number: PYSIDE-213 Change-Id: Ic0f383c3d93b905885f76788d32d62ba37ed9d2f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/pyside2/PySide2/QtWidgets')
-rw-r--r--sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml7
1 files changed, 5 insertions, 2 deletions
diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
index 9d3e70be..1663e4f4 100644
--- a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
+++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
@@ -2507,10 +2507,13 @@
</modify-function>
<modify-function signature="clear()">
<inject-code class="target" position="beginning">
+ Shiboken::BindingManager&amp; bm = Shiboken::BindingManager::instance();
for (int i = 0; i &lt; %CPPSELF.count(); i++) {
QWidget* widget = %CPPSELF.widget(i);
- Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](widget));
- Shiboken::Object::setParent(0, pyWidget);
+ if (bm.hasWrapper(widget)) {
+ Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](widget));
+ Shiboken::Object::releaseOwnership(pyWidget);
+ }
}
%CPPSELF.%FUNCTION_NAME();
</inject-code>