aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-10-13 16:42:50 -0300
committerrenatofilho <renato.filho@openbossa.org>2010-10-13 17:01:05 -0300
commite71b215f0bb4c6b53bd74a66ab856426df51f140 (patch)
tree79ab2ad9382cf5f8d718a41641fbf8c9885a48a9 /plugins
parent4c8660413a66b8e006687def786d9a82c6870094 (diff)
Fixed reference leak on uiloader.
Fixes bug #392 Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/customwidget.cpp11
1 files changed, 7 insertions, 4 deletions
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<QWidget*>::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<QWidget*>(Shiboken::getCppPointer(result, result->ob_type));
}