##// END OF EJS Templates
- fixed support for QList<AnyObject*>* (which occured with QObjectList* return values)...
florianlink -
r77:0b14472ff76a
parent child
Show More
@@ -80,11 +80,16 PyObject* PythonQtConv::ConvertQtValueToPython(const PythonQtMethodInfo::Paramet
80 } else if ((info.typeId == PythonQtMethodInfo::Unknown || info.typeId >= QMetaType::User) &&
80 } else if ((info.typeId == PythonQtMethodInfo::Unknown || info.typeId >= QMetaType::User) &&
81 info.name.startsWith("QList<")) {
81 info.name.startsWith("QList<")) {
82 // it is a QList template:
82 // it is a QList template:
83 // (TODO: check what happens if this is a pointer type?!)
84 QByteArray innerType = info.name.mid(6,info.name.length()-7);
83 QByteArray innerType = info.name.mid(6,info.name.length()-7);
85 if (innerType.endsWith("*")) {
84 if (innerType.endsWith("*")) {
86 innerType.truncate(innerType.length()-1);
85 innerType.truncate(innerType.length()-1);
87 return ConvertQListOfPointerTypeToPythonList((QList<void*>*)data, innerType);
86 QList<void*>* listPtr;
87 if (info.isPointer) {
88 listPtr = *((QList<void*>**)data);
89 } else {
90 listPtr = (QList<void*>*)data;
91 }
92 return ConvertQListOfPointerTypeToPythonList(listPtr, innerType);
88 }
93 }
89 }
94 }
90
95
@@ -185,7 +185,13 PyObject *PythonQtSlotFunction_Call(PyObject *func, PyObject *args, PyObject *kw
185 PythonQtSlotInfo* info = f->m_ml;
185 PythonQtSlotInfo* info = f->m_ml;
186 if (PyObject_TypeCheck(f->m_self, &PythonQtInstanceWrapper_Type)) {
186 if (PyObject_TypeCheck(f->m_self, &PythonQtInstanceWrapper_Type)) {
187 PythonQtInstanceWrapper* self = (PythonQtInstanceWrapper*) f->m_self;
187 PythonQtInstanceWrapper* self = (PythonQtInstanceWrapper*) f->m_self;
188 return PythonQtSlotFunction_CallImpl(self->classInfo(), self->_obj, info, args, kw, self->_wrappedPtr);
188 if (!info->isClassDecorator() && (self->_obj==NULL && self->_wrappedPtr==NULL)) {
189 QString error = QString("Trying to call '") + f->m_ml->slotName() + "' on a destroyed " + self->classInfo()->className() + " object";
190 PyErr_SetString(PyExc_ValueError, error.toLatin1().data());
191 return NULL;
192 } else {
193 return PythonQtSlotFunction_CallImpl(self->classInfo(), self->_obj, info, args, kw, self->_wrappedPtr);
194 }
189 } else if (f->m_self->ob_type == &PythonQtClassWrapper_Type) {
195 } else if (f->m_self->ob_type == &PythonQtClassWrapper_Type) {
190 PythonQtClassWrapper* type = (PythonQtClassWrapper*) f->m_self;
196 PythonQtClassWrapper* type = (PythonQtClassWrapper*) f->m_self;
191 if (info->isClassDecorator()) {
197 if (info->isClassDecorator()) {
@@ -198,6 +204,11 PyObject *PythonQtSlotFunction_Call(PyObject *func, PyObject *args, PyObject *kw
198 if (PyObject_TypeCheck(firstArg, (PyTypeObject*)&PythonQtInstanceWrapper_Type)
204 if (PyObject_TypeCheck(firstArg, (PyTypeObject*)&PythonQtInstanceWrapper_Type)
199 && ((PythonQtInstanceWrapper*)firstArg)->classInfo()->inherits(type->classInfo())) {
205 && ((PythonQtInstanceWrapper*)firstArg)->classInfo()->inherits(type->classInfo())) {
200 PythonQtInstanceWrapper* self = (PythonQtInstanceWrapper*)firstArg;
206 PythonQtInstanceWrapper* self = (PythonQtInstanceWrapper*)firstArg;
207 if (!info->isClassDecorator() && (self->_obj==NULL && self->_wrappedPtr==NULL)) {
208 QString error = QString("Trying to call '") + f->m_ml->slotName() + "' on a destroyed " + self->classInfo()->className() + " object";
209 PyErr_SetString(PyExc_ValueError, error.toLatin1().data());
210 return NULL;
211 }
201 // strip the first argument...
212 // strip the first argument...
202 PyObject* newargs = PyTuple_GetSlice(args, 1, argc);
213 PyObject* newargs = PyTuple_GetSlice(args, 1, argc);
203 PyObject* result = PythonQtSlotFunction_CallImpl(self->classInfo(), self->_obj, info, newargs, kw, self->_wrappedPtr);
214 PyObject* result = PythonQtSlotFunction_CallImpl(self->classInfo(), self->_obj, info, newargs, kw, self->_wrappedPtr);
@@ -144,14 +144,9 void PythonQtStdDecorators::setParent(QObject* o, QObject* parent)
144 o->setParent(parent);
144 o->setParent(parent);
145 }
145 }
146
146
147 QVariantList PythonQtStdDecorators::children(QObject* o)
147 const QObjectList* PythonQtStdDecorators::children(QObject* o)
148 {
148 {
149 QVariantList v;
149 return &o->children();
150 QListIterator<QObject*> it(o->children());
151 while (it.hasNext()) {
152 v << qVariantFromValue(it.next());
153 }
154 return v;
155 }
150 }
156
151
157 QString PythonQtStdDecorators::tr(QObject* obj, const QByteArray& text, const QByteArray& ambig, int n)
152 QString PythonQtStdDecorators::tr(QObject* obj, const QByteArray& text, const QByteArray& ambig, int n)
@@ -70,7 +70,7 public slots:
70 QObject* parent(QObject* o);
70 QObject* parent(QObject* o);
71 void setParent(QObject* o, QObject* parent);
71 void setParent(QObject* o, QObject* parent);
72
72
73 QVariantList children(QObject* o);
73 const QObjectList* children(QObject* o);
74
74
75 double static_Qt_qAbs(double a) { return qAbs(a); }
75 double static_Qt_qAbs(double a) { return qAbs(a); }
76 double static_Qt_qBound(double a,double b,double c) { return qBound(a,b,c); }
76 double static_Qt_qBound(double a,double b,double c) { return qBound(a,b,c); }
General Comments 0
You need to be logged in to leave comments. Login now