forked from bartvdbraak/blender
fix for memory leak, use Key Errors for pyrna getitem access & idprops
This commit is contained in:
parent
49c47fbf30
commit
d3794d9f94
@ -2344,13 +2344,8 @@ int RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, Prope
|
|||||||
|
|
||||||
if(use_id_prop) { /* look up property name in current struct */
|
if(use_id_prop) { /* look up property name in current struct */
|
||||||
IDProperty *group= RNA_struct_idproperties(ptr, 0);
|
IDProperty *group= RNA_struct_idproperties(ptr, 0);
|
||||||
if(!group)
|
if(group && rna_token_strip_quotes(token))
|
||||||
return 0;
|
|
||||||
|
|
||||||
if(rna_token_strip_quotes(token))
|
|
||||||
prop= (PropertyRNA *)IDP_GetPropertyFromGroup(group, token+1);
|
prop= (PropertyRNA *)IDP_GetPropertyFromGroup(group, token+1);
|
||||||
else
|
|
||||||
prop= NULL;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
prop= RNA_struct_find_property(&curptr, token);
|
prop= RNA_struct_find_property(&curptr, token);
|
||||||
|
@ -322,7 +322,7 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val)
|
|||||||
MEM_freeN(pkey);
|
MEM_freeN(pkey);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
PyErr_SetString( PyExc_RuntimeError, "property not found in group" );
|
PyErr_SetString( PyExc_KeyError, "property not found in group" );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,7 +336,7 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val)
|
|||||||
|
|
||||||
err = BPy_IDProperty_Map_ValidateAndCreate(_PyUnicode_AsString(key), prop, val);
|
err = BPy_IDProperty_Map_ValidateAndCreate(_PyUnicode_AsString(key), prop, val);
|
||||||
if (err) {
|
if (err) {
|
||||||
PyErr_SetString( PyExc_RuntimeError, err );
|
PyErr_SetString( PyExc_KeyError, err );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1218,14 +1218,14 @@ static PyObject *pyrna_struct_subscript( BPy_StructRNA *self, PyObject *key )
|
|||||||
group= RNA_struct_idproperties(&self->ptr, 0);
|
group= RNA_struct_idproperties(&self->ptr, 0);
|
||||||
|
|
||||||
if(group==NULL) {
|
if(group==NULL) {
|
||||||
PyErr_Format( PyExc_TypeError, "key \"%s\" not found", name);
|
PyErr_Format( PyExc_KeyError, "key \"%s\" not found", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
idprop= IDP_GetPropertyFromGroup(group, name);
|
idprop= IDP_GetPropertyFromGroup(group, name);
|
||||||
|
|
||||||
if(idprop==NULL) {
|
if(idprop==NULL) {
|
||||||
PyErr_Format( PyExc_TypeError, "key \"%s\" not found", name);
|
PyErr_Format( PyExc_KeyError, "key \"%s\" not found", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user