[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34615] trunk/blender/source/blender: fix crash from report [#25746] Adding keyframes to nested custom properties (IDProperties) of a bone causes segfault
Campbell Barton
ideasman42 at gmail.com
Wed Feb 2 00:53:55 CET 2011
Revision: 34615
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34615
Author: campbellbarton
Date: 2011-02-01 23:53:54 +0000 (Tue, 01 Feb 2011)
Log Message:
-----------
fix crash from report [#25746] Adding keyframes to nested custom properties (IDProperties) of a bone causes segfault
though keyframing still doesn't work, it gives an error instead.
also use const char * in more parts of the py/rna api.
Modified Paths:
--------------
trunk/blender/source/blender/makesrna/RNA_access.h
trunk/blender/source/blender/makesrna/intern/rna_access.c
trunk/blender/source/blender/python/intern/bpy_rna.c
Modified: trunk/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_access.h 2011-02-01 23:51:52 UTC (rev 34614)
+++ trunk/blender/source/blender/makesrna/RNA_access.h 2011-02-01 23:53:54 UTC (rev 34615)
@@ -750,8 +750,8 @@
/* efficient functions to set properties for arrays */
int RNA_property_collection_raw_array(PointerRNA *ptr, PropertyRNA *prop, PropertyRNA *itemprop, RawArray *array);
-int RNA_property_collection_raw_get(struct ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, char *propname, void *array, RawPropertyType type, int len);
-int RNA_property_collection_raw_set(struct ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, char *propname, void *array, RawPropertyType type, int len);
+int RNA_property_collection_raw_get(struct ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, const char *propname, void *array, RawPropertyType type, int len);
+int RNA_property_collection_raw_set(struct ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, const char *propname, void *array, RawPropertyType type, int len);
int RNA_raw_type_sizeof(RawPropertyType type);
RawPropertyType RNA_property_raw_type(PropertyRNA *prop);
Modified: trunk/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_access.c 2011-02-01 23:51:52 UTC (rev 34614)
+++ trunk/blender/source/blender/makesrna/intern/rna_access.c 2011-02-01 23:53:54 UTC (rev 34615)
@@ -2460,7 +2460,7 @@
}
}
-static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, char *propname, void *inarray, RawPropertyType intype, int inlen, int set)
+static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, const char *propname, void *inarray, RawPropertyType intype, int inlen, int set)
{
StructRNA *ptype;
PointerRNA itemptr;
@@ -2762,12 +2762,12 @@
return prop->rawtype;
}
-int RNA_property_collection_raw_get(ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, char *propname, void *array, RawPropertyType type, int len)
+int RNA_property_collection_raw_get(ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, const char *propname, void *array, RawPropertyType type, int len)
{
return rna_raw_access(reports, ptr, prop, propname, array, type, len, 0);
}
-int RNA_property_collection_raw_set(ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, char *propname, void *array, RawPropertyType type, int len)
+int RNA_property_collection_raw_set(ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, const char *propname, void *array, RawPropertyType type, int len)
{
return rna_raw_access(reports, ptr, prop, propname, array, type, len, 1);
}
@@ -3423,12 +3423,19 @@
IDProperty *needle;
BLI_assert(ptr->id.data != NULL);
+
+ /* TODO, Support Bones/PoseBones. no pointers stored to the bones from here, only the ID. See example in [#25746]
+ * unless this is added only way to find this is to also search all bones and pose bones of an armature or object */
RNA_id_pointer_create(ptr->id.data, &id_ptr);
haystack= RNA_struct_idprops(&id_ptr, FALSE);
- needle= ptr->data;
-
- return rna_idp_path(&id_ptr, haystack, needle, NULL);
+ if(haystack) { /* can fail when called on bones */
+ needle= ptr->data;
+ return rna_idp_path(&id_ptr, haystack, needle, NULL);
+ }
+ else {
+ return NULL;
+ }
}
char *RNA_path_from_ID_to_struct(PointerRNA *ptr)
Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c 2011-02-01 23:51:52 UTC (rev 34614)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c 2011-02-01 23:53:54 UTC (rev 34615)
@@ -435,9 +435,9 @@
int pyrna_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value, const char *error_prefix)
{
if(RNA_enum_value_from_id(item, identifier, value) == 0) {
- char *enum_str= BPy_enum_as_string(item);
+ const char *enum_str= BPy_enum_as_string(item);
PyErr_Format(PyExc_TypeError, "%s: '%.200s' not found in (%s)", error_prefix, identifier, enum_str);
- MEM_freeN(enum_str);
+ MEM_freeN((void *)enum_str);
return -1;
}
@@ -516,13 +516,13 @@
static PyObject *pyrna_struct_str( BPy_StructRNA *self )
{
PyObject *ret;
- char *name;
+ const char *name;
/* print name if available */
name= RNA_struct_name_get_alloc(&self->ptr, NULL, FALSE);
if(name) {
ret= PyUnicode_FromFormat( "<bpy_struct, %.200s(\"%.200s\")>", RNA_struct_identifier(self->ptr.type), name);
- MEM_freeN(name);
+ MEM_freeN((void *)name);
return ret;
}
@@ -540,11 +540,11 @@
}
else {
PyObject *ret;
- char *path;
+ const char *path;
path= RNA_path_from_ID_to_struct(&self->ptr);
if(path) {
ret= PyUnicode_FromFormat( "bpy.data.%s[\"%s\"].%s", BKE_idcode_to_name_plural(GS(id->name)), id->name+2, path);
- MEM_freeN(path);
+ MEM_freeN((void *)path);
}
else { /* cant find, print something sane */
ret= PyUnicode_FromFormat( "bpy.data.%s[\"%s\"]...%s", BKE_idcode_to_name_plural(GS(id->name)), id->name+2, RNA_struct_identifier(self->ptr.type));
@@ -558,7 +558,7 @@
{
PyObject *ret;
PointerRNA ptr;
- char *name;
+ const char *name;
const char *type_id= NULL;
char type_fmt[64]= "";
int type= RNA_property_type(self->prop);
@@ -591,7 +591,7 @@
if(name) {
ret= PyUnicode_FromFormat( "<bpy_%.200s, %.200s.%.200s(\"%.200s\")>", type_fmt, RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop), name);
- MEM_freeN(name);
+ MEM_freeN((void *)name);
return ret;
}
}
@@ -603,7 +603,7 @@
{
ID *id= self->ptr.id.data;
PyObject *ret;
- char *path;
+ const char *path;
if(id == NULL)
return pyrna_prop_str(self); /* fallback */
@@ -611,7 +611,7 @@
path= RNA_path_from_ID_to_property(&self->ptr, self->prop);
if(path) {
ret= PyUnicode_FromFormat( "bpy.data.%s[\"%s\"].%s", BKE_idcode_to_name_plural(GS(id->name)), id->name+2, path);
- MEM_freeN(path);
+ MEM_freeN((void *)path);
}
else { /* cant find, print something sane */
ret= PyUnicode_FromFormat( "bpy.data.%s[\"%s\"]...%s", BKE_idcode_to_name_plural(GS(id->name)), id->name+2, RNA_property_identifier(self->prop));
@@ -682,7 +682,7 @@
static int pyrna_string_to_enum(PyObject *item, PointerRNA *ptr, PropertyRNA *prop, int *val, const char *error_prefix)
{
- char *param= _PyUnicode_AsString(item);
+ const char *param= _PyUnicode_AsString(item);
if (param==NULL) {
const char *enum_str= pyrna_enum_as_string(ptr, prop);
@@ -714,7 +714,7 @@
*r_value= 0;
while (_PySet_NextEntry(value, &pos, &key, &hash)) {
- char *param= _PyUnicode_AsString(key);
+ const char *param= _PyUnicode_AsString(key);
if(param==NULL) {
PyErr_Format(PyExc_TypeError, "%.200s expected a string. found a %.200s", error_prefix, Py_TYPE(key)->tp_name);
@@ -812,7 +812,7 @@
ret= PyUnicode_FromString(item->identifier);
}
else {
- char *ptr_name= RNA_struct_name_get_alloc(ptr, NULL, FALSE);
+ const char *ptr_name= RNA_struct_name_get_alloc(ptr, NULL, FALSE);
/* prefer not fail silently incase of api errors, maybe disable it later */
printf("RNA Warning: Current value \"%d\" matches no enum in '%s', '%s', '%s'\n", val, RNA_struct_identifier(ptr->type), ptr_name, RNA_property_identifier(prop));
@@ -824,9 +824,9 @@
#endif
if(ptr_name)
- MEM_freeN(ptr_name);
+ MEM_freeN((void *)ptr_name);
- ret = PyUnicode_FromString( "" );
+ ret = PyUnicode_FromString("");
}
if(free)
@@ -863,7 +863,7 @@
case PROP_STRING:
{
int subtype= RNA_property_subtype(prop);
- char *buf;
+ const char *buf;
buf = RNA_property_string_get_alloc(ptr, prop, NULL, -1);
#ifdef USE_STRING_COERCE
/* only file paths get special treatment, they may contain non utf-8 chars */
@@ -876,7 +876,7 @@
#else // USE_STRING_COERCE
ret= PyUnicode_FromString(buf);
#endif // USE_STRING_COERCE
- MEM_freeN(buf);
+ MEM_freeN((void *)buf);
break;
}
case PROP_ENUM:
@@ -1289,7 +1289,7 @@
if(pyrna_pydict_to_props(&itemptr, item, 1, "Converting a python list to an RNA collection")==-1) {
PyObject *msg= PyC_ExceptionBuffer();
- char *msg_char= _PyUnicode_AsString(msg);
+ const char *msg_char= _PyUnicode_AsString(msg);
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s error converting a member of a collection from a dicts into an RNA collection, failed with: %s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), msg_char);
@@ -1911,7 +1911,7 @@
PointerRNA newptr; /* not used, just so RNA_property_collection_lookup_string runs */
/* key in dict style check */
- char *keyname = _PyUnicode_AsString(value);
+ const char *keyname = _PyUnicode_AsString(value);
if(keyname==NULL) {
PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.__contains__: expected a string");
@@ -1927,7 +1927,7 @@
static int pyrna_struct_contains(BPy_StructRNA *self, PyObject *value)
{
IDProperty *group;
- char *name = _PyUnicode_AsString(value);
+ const char *name = _PyUnicode_AsString(value);
if (!name) {
PyErr_SetString(PyExc_TypeError, "bpy_struct.__contains__: expected a string");
@@ -1990,7 +1990,7 @@
{
/* mostly copied from BPy_IDGroup_Map_GetItem */
IDProperty *group, *idprop;
- char *name= _PyUnicode_AsString(key);
+ const char *name= _PyUnicode_AsString(key);
if(RNA_struct_idprops_check(self->ptr.type)==0) {
PyErr_SetString(PyExc_TypeError, "this type doesn't support IDProperties");
@@ -2126,7 +2126,7 @@
/* for keyframes and drivers */
static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefix, const char *path,
- char **path_full, int *index)
+ const char **path_full, int *index)
{
const int is_idbase= RNA_struct_is_ID(ptr->type);
PropertyRNA *prop;
@@ -2201,10 +2201,10 @@
/* internal use for insert and delete */
static int pyrna_struct_keyframe_parse(PointerRNA *ptr, PyObject *args, PyObject *kw, const char *parse_str, const char *error_prefix,
- char **path_full, int *index, float *cfra, char **group_name) /* return values */
+ const char **path_full, int *index, float *cfra, const char **group_name) /* return values */
{
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list