Fix PyAPI crash assigning/deleting id-properties

Caused by D113.
This commit is contained in:
Campbell Barton 2017-05-06 23:26:18 +10:00
parent 0eef40ed51
commit 5cdd94a58e
1 changed files with 11 additions and 7 deletions

View File

@ -3271,13 +3271,17 @@ static int pyrna_struct_ass_subscript(BPy_StructRNA *self, PyObject *key, PyObje
return -1;
}
BPy_StructRNA *val = (BPy_StructRNA *)value;
if (val && self->ptr.type && val->ptr.type) {
if (!RNA_struct_idprops_datablock_allowed(self->ptr.type) &&
RNA_struct_idprops_contains_datablock(val->ptr.type))
{
PyErr_SetString(PyExc_TypeError, "bpy_struct[key] = val: datablock id properties not supported for this type");
return -1;
if (value && BPy_StructRNA_Check(value)) {
BPy_StructRNA *val = (BPy_StructRNA *)value;
if (val && self->ptr.type && val->ptr.type) {
if (!RNA_struct_idprops_datablock_allowed(self->ptr.type) &&
RNA_struct_idprops_contains_datablock(val->ptr.type))
{
PyErr_SetString(
PyExc_TypeError,
"bpy_struct[key] = val: datablock id properties not supported for this type");
return -1;
}
}
}