fix for crash when using a NULL context from python

This commit is contained in:
2010-01-27 10:54:11 +00:00
parent 2cb23d03ef
commit 49abcd49f1

View File

@@ -1898,11 +1898,16 @@ static PyObject *pyrna_struct_getattro( BPy_StructRNA *self, PyObject *pyname )
ret = pyrna_func_to_py((BPy_DummyPointerRNA *)self, func);
}
else if (self->ptr.type == &RNA_Context) {
bContext *C = self->ptr.data;
if(C==NULL) {
PyErr_Format( PyExc_AttributeError, "StructRNA Context is 'NULL', can't get \"%.200s\" from context", name);
ret= NULL;
}
else {
PointerRNA newptr;
ListBase newlb;
int done;
done= CTX_data_get(self->ptr.data, name, &newptr, &newlb);
int done= CTX_data_get(C, name, &newptr, &newlb);
if(done==1) { /* found */
if (newptr.data) {
@@ -1936,6 +1941,7 @@ static PyObject *pyrna_struct_getattro( BPy_StructRNA *self, PyObject *pyname )
BLI_freelistN(&newlb);
}
}
else {
#if 0
PyErr_Format( PyExc_AttributeError, "StructRNA - Attribute \"%.200s\" not found", name);