##// END OF EJS Templates
improved error handling on destroyed objects (since static access should still be possible)...
florianlink -
r78:eaf55225d8f6
parent child
Show More
@@ -228,6 +228,7 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 if (wrapper->_obj) {
231 232 // only the properties are missing, the rest is already available from
232 233 // PythonQtClassWrapper...
233 234 QStringList l = wrapper->classInfo()->propertyList();
@@ -240,6 +241,7 static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name)
240 241 std::cerr << "PythonQtInstanceWrapper: something is wrong, could not get attribute " << name.toLatin1().data();
241 242 }
242 243 }
244 }
243 245 // Note: we do not put children into the dict, is would look confusing?!
244 246 return dict;
245 247 }
@@ -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:
@@ -295,7 +295,7 static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name)
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