summaryrefslogtreecommitdiffstats
path: root/PySide/QtUiTools/glue/uitools_loadui.h
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-10-13 16:43:15 -0300
committerrenatofilho <renato.filho@openbossa.org>2010-10-13 17:02:13 -0300
commit3ad81fcdaaa9155a83f0d9112ba6f0b324312346 (patch)
treee37a8127ed6054df80160e5d0a8ad0c8345e3edf /PySide/QtUiTools/glue/uitools_loadui.h
parente71b215f0bb4c6b53bd74a66ab856426df51f140 (diff)
downloadpyside-3ad81fcdaaa9155a83f0d9112ba6f0b324312346.tar.gz
pyside-3ad81fcdaaa9155a83f0d9112ba6f0b324312346.tar.xz
pyside-3ad81fcdaaa9155a83f0d9112ba6f0b324312346.zip
Used original object in parent dictionary.
This allow use the object as arguments in any functions. Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'PySide/QtUiTools/glue/uitools_loadui.h')
-rw-r--r--PySide/QtUiTools/glue/uitools_loadui.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/PySide/QtUiTools/glue/uitools_loadui.h b/PySide/QtUiTools/glue/uitools_loadui.h
index 5729b5f..8f6df63 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), PyWeakref_NewProxy(pyChild, 0));
+ PyObject_SetAttrString(pyParent, qPrintable(name), pyChild);
Shiboken::setParent(pyParent, pyChild);
_populate_parent(pyChild, qobject_cast<QObject*>(child));
@@ -31,16 +31,21 @@ quiloader_load_ui_from_device(QUiLoader* self, QIODevice* dev, QWidget *parent)
{
QWidget *w = self->load(dev, parent);
if (w) {
+ QObject* _parent = parent;
+ if (!_parent)
+ _parent = w;
+
if (parent && parent->layout())
parent->layout()->deleteLater();
PyObject* pyParent = Shiboken::Converter<QWidget*>::toPython(w);
- _populate_parent(pyParent, w);
+ _populate_parent(pyParent, _parent);
return pyParent;
}
- PyErr_SetString(PyExc_RuntimeError, "Unable to open ui file");
+ if (!PyErr_Occurred())
+ PyErr_SetString(PyExc_RuntimeError, "Unable to open ui file");
return 0;
}
@@ -66,6 +71,7 @@ quiloader_load_ui(QUiLoader* self, const QString &ui_file, QWidget *parent)
return Shiboken::Converter<QWidget*>::toPython(w);
}
}
- PyErr_SetString(PyExc_RuntimeError, "Unable to open ui file");
- return 0;
+ if (!PyErr_Occurred())
+ PyErr_SetString(PyExc_RuntimeError, "Unable to open ui file");
+ return 0;
}