summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-10-06 18:54:51 -0300
committerrenatofilho <renato.filho@openbossa.org>2010-10-07 12:18:26 -0300
commit83533ddc5d89feb046863b4dacc86be3967e4a6b (patch)
tree4d0bc9b5dd0587a17aaf8257a0a8637c38a4dccf
parente75b82fdf6e9903e7264a1bc962ab7ed42c53bcd (diff)
downloadpyside-83533ddc5d89feb046863b4dacc86be3967e4a6b.tar.gz
pyside-83533ddc5d89feb046863b4dacc86be3967e4a6b.tar.xz
pyside-83533ddc5d89feb046863b4dacc86be3967e4a6b.zip
Used proxy object in QUiLoader loaded widget to avoid cyclic reference.
Reviewer: Hugo Parente Lima <hugo.pl@gmail.com> Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r--PySide/QtUiTools/glue/uitools_loadui.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/PySide/QtUiTools/glue/uitools_loadui.h b/PySide/QtUiTools/glue/uitools_loadui.h
index bce1367..5729b5f 100644
--- a/PySide/QtUiTools/glue/uitools_loadui.h
+++ b/PySide/QtUiTools/glue/uitools_loadui.h
@@ -18,7 +18,7 @@ _populate_parent(PyObject* pyParent, QObject *parent)
bool has_attr = PyObject_HasAttrString(pyParent, qPrintable(name));
Shiboken::AutoDecRef pyChild(Shiboken::Converter<QObject*>::toPython(child));
if (!has_attr)
- PyObject_SetAttrString(pyParent, qPrintable(name), pyChild);
+ PyObject_SetAttrString(pyParent, qPrintable(name), PyWeakref_NewProxy(pyChild, 0));
Shiboken::setParent(pyParent, pyChild);
_populate_parent(pyChild, qobject_cast<QObject*>(child));
@@ -53,14 +53,17 @@ quiloader_load_ui(QUiLoader* self, const QString &ui_file, QWidget *parent)
QWidget* w = self->load(&fd, parent);
fd.close();
if (w != 0) {
- PyObject* pyParent = Shiboken::Converter<QWidget*>::toPython(w);
+ QObject *_parent = parent;
+ if (!_parent)
+ _parent = w;
+ Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(_parent));
if (parent && parent->layout())
parent->layout()->deleteLater();
- _populate_parent(pyParent, w);
+ _populate_parent(pyParent, _parent);
- return pyParent;
+ return Shiboken::Converter<QWidget*>::toPython(w);
}
}
PyErr_SetString(PyExc_RuntimeError, "Unable to open ui file");