diff options
author | renatofilho <renato.filho@openbossa.org> | 2010-10-06 18:54:51 -0300 |
---|---|---|
committer | renatofilho <renato.filho@openbossa.org> | 2010-10-07 12:18:26 -0300 |
commit | 83533ddc5d89feb046863b4dacc86be3967e4a6b (patch) | |
tree | 4d0bc9b5dd0587a17aaf8257a0a8637c38a4dccf | |
parent | e75b82fdf6e9903e7264a1bc962ab7ed42c53bcd (diff) |
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.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/PySide/QtUiTools/glue/uitools_loadui.h b/PySide/QtUiTools/glue/uitools_loadui.h index bce1367c1..5729b5f30 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"); |