Fix QObject::findChildren and QObject::findChild methods.
QUiTools unit tests uses these functions and will fail without this patch. Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Reviewer: Anderson Lizardo <anderson.lizardo@openbossa.org>
This commit is contained in:
parent
771c2be893
commit
718dd06ecd
2 changed files with 39 additions and 21 deletions
30
PySide/QtCore/glue/qobject_findchild.cpp
Normal file
30
PySide/QtCore/glue/qobject_findchild.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
static QObject* _findChildHelper(const QObject* parent, const QString& name, PyTypeObject* desiredType)
|
||||
{
|
||||
foreach(QObject* child, parent->children()) {
|
||||
Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QObject*](child));
|
||||
if (PyType_IsSubtype(pyChild->ob_type, desiredType)
|
||||
&& (name.isNull() || name == child->objectName())) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
QObject* obj;
|
||||
foreach(QObject* child, parent->children()) {
|
||||
obj = _findChildHelper(child, name, desiredType);
|
||||
if (obj)
|
||||
return obj;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _findChildrenHelper(const QObject* parent, const QString& name, PyTypeObject* desiredType, PyObject* result)
|
||||
{
|
||||
foreach(QObject* child, parent->children()) {
|
||||
Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QObject*](child));
|
||||
if (PyType_IsSubtype(pyChild->ob_type, desiredType)
|
||||
&& (name.isNull() || name == child->objectName())) {
|
||||
PyList_Append(result, pyChild);
|
||||
}
|
||||
_findChildrenHelper(child, name, desiredType, result);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue