From e71b215f0bb4c6b53bd74a66ab856426df51f140 Mon Sep 17 00:00:00 2001 From: renatofilho Date: Wed, 13 Oct 2010 16:42:50 -0300 Subject: Fixed reference leak on uiloader. Fixes bug #392 Reviewer: Luciano Wolf Marcelo Lira --- plugins/customwidget.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/customwidget.cpp b/plugins/customwidget.cpp index 78e0064d2..156b37306 100644 --- a/plugins/customwidget.cpp +++ b/plugins/customwidget.cpp @@ -91,7 +91,7 @@ QString PyCustomWidget::whatsThis() const } QWidget *PyCustomWidget::createWidget(QWidget *parent) -{ +{ //Create a python instance and return cpp object PyObject* pyParent; bool unkowParent = false; @@ -100,8 +100,11 @@ QWidget *PyCustomWidget::createWidget(QWidget *parent) if (!pyParent) { pyParent = Shiboken::Converter::toPython(parent); unkowParent = true; + } else { + Py_INCREF(pyParent); } } else { + Py_INCREF(Py_None); pyParent = Py_None; } @@ -110,14 +113,14 @@ QWidget *PyCustomWidget::createWidget(QWidget *parent) //Call python constructor PyObject* result = PyObject_CallObject(m_data->pyObject, pyArgs); - + QWidget* widget = 0; if (result) { if (unkowParent) //if parent does not exists in python, transfer the ownership to cpp - Shiboken::BindingManager::instance().transferOwnershipToCpp(result); + Shiboken::BindingManager::instance().transferOwnershipToCpp(result); else Shiboken::setParent(pyParent, result); - + widget = reinterpret_cast(Shiboken::getCppPointer(result, result->ob_type)); } -- cgit v1.2.3