@@ -228,16 +228,18 static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name) | |||
|
228 | 228 | PyObject* dict = PyBaseObject_Type.tp_getattro(obj, name); |
|
229 | 229 | dict = PyDict_Copy(dict); |
|
230 | 230 | |
|
231 | // only the properties are missing, the rest is already available from | |
|
232 | // PythonQtClassWrapper... | |
|
233 | QStringList l = wrapper->classInfo()->propertyList(); | |
|
234 | foreach (QString name, l) { | |
|
235 | PyObject* o = PyObject_GetAttrString(obj, name.toLatin1().data()); | |
|
236 | if (o) { | |
|
237 | PyDict_SetItemString(dict, name.toLatin1().data(), o); | |
|
238 | Py_DECREF(o); | |
|
239 | } else { | |
|
240 | std::cerr << "PythonQtInstanceWrapper: something is wrong, could not get attribute " << name.toLatin1().data(); | |
|
231 | if (wrapper->_obj) { | |
|
232 | // only the properties are missing, the rest is already available from | |
|
233 | // PythonQtClassWrapper... | |
|
234 | QStringList l = wrapper->classInfo()->propertyList(); | |
|
235 | foreach (QString name, l) { | |
|
236 | PyObject* o = PyObject_GetAttrString(obj, name.toLatin1().data()); | |
|
237 | if (o) { | |
|
238 | PyDict_SetItemString(dict, name.toLatin1().data(), o); | |
|
239 | Py_DECREF(o); | |
|
240 | } else { | |
|
241 | std::cerr << "PythonQtInstanceWrapper: something is wrong, could not get attribute " << name.toLatin1().data(); | |
|
242 | } | |
|
241 | 243 | } |
|
242 | 244 | } |
|
243 | 245 | // Note: we do not put children into the dict, is would look confusing?! |
@@ -251,12 +253,6 static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name) | |||
|
251 | 253 | } |
|
252 | 254 | PyErr_Clear(); |
|
253 | 255 | |
|
254 | if (!wrapper->_obj && !wrapper->_wrappedPtr) { | |
|
255 | QString error = QString("Trying to read attribute '") + attributeName + "' from a destroyed " + wrapper->classInfo()->className() + " object"; | |
|
256 | PyErr_SetString(PyExc_ValueError, error.toLatin1().data()); | |
|
257 | return NULL; | |
|
258 | } | |
|
259 | ||
|
260 | 256 | // mlabDebugConst("Python","get " << attributeName); |
|
261 | 257 | |
|
262 | 258 | // TODO: dynamic properties are missing |
@@ -271,6 +267,10 static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name) | |||
|
271 | 267 | Py_INCREF(Py_None); |
|
272 | 268 | return Py_None; |
|
273 | 269 | } |
|
270 | } else { | |
|
271 | QString error = QString("Trying to read property '") + attributeName + "' from a destroyed " + wrapper->classInfo()->className() + " object"; | |
|
272 | PyErr_SetString(PyExc_ValueError, error.toLatin1().data()); | |
|
273 | return NULL; | |
|
274 | 274 | } |
|
275 | 275 | break; |
|
276 | 276 | case PythonQtMemberInfo::Slot: |
@@ -278,24 +278,24 static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name) | |||
|
278 | 278 | break; |
|
279 | 279 | case PythonQtMemberInfo::EnumValue: |
|
280 | 280 | { |
|
281 | PyObject* enumValue = member._enumValue; | |
|
282 | Py_INCREF(enumValue); | |
|
283 | return enumValue; | |
|
281 | PyObject* enumValue = member._enumValue; | |
|
282 | Py_INCREF(enumValue); | |
|
283 | return enumValue; | |
|
284 | 284 | } |
|
285 | 285 | break; |
|
286 | 286 | case PythonQtMemberInfo::EnumWrapper: |
|
287 | 287 | { |
|
288 | PyObject* enumWrapper = member._enumWrapper; | |
|
289 | Py_INCREF(enumWrapper); | |
|
290 | return enumWrapper; | |
|
288 | PyObject* enumWrapper = member._enumWrapper; | |
|
289 | Py_INCREF(enumWrapper); | |
|
290 | return enumWrapper; | |
|
291 | 291 | } |
|
292 | 292 | break; |
|
293 |
|
|
|
294 |
|
|
|
293 | default: | |
|
294 | // is an invalid type, go on | |
|
295 | 295 | break; |
|
296 | 296 | } |
|
297 | 297 | |
|
298 | // look for the interal methods (className(), help()) | |
|
298 | // look for the internal methods (className(), help()) | |
|
299 | 299 | PyObject* internalMethod = Py_FindMethod( PythonQtInstanceWrapper_methods, obj, (char*)attributeName); |
|
300 | 300 | if (internalMethod) { |
|
301 | 301 | return internalMethod; |
General Comments 0
You need to be logged in to leave comments.
Login now