Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2013-04-22 17:22:07 +0400
committerJoshua Leung <aligorith@gmail.com>2013-04-22 17:22:07 +0400
commit5580b568765a89bbe02f21cee839c585260ef6c2 (patch)
tree9be5664cf38f1fb7c46dd07ae81e65bee7fcfb67 /source/blender/blenkernel/intern/anim_sys.c
parent319036f2d57c3fd9463648c4187ed4a387b0ab33 (diff)
Bugfix [#34836] Crash when driver variable has path == 'data'
Most of the places which relied on RNA_path_resolve() did so believing that if it returned true, that it had found a valid property, and that the returned pointer+property combination would be what the path referred to. However, it turns out that if the property at the end of the path turns out to be a "pointer" property (e.g. "data" for Object.data), this would automatically become the pointer part, while the prop part would be set to null. Hence, if a user accidentally (or otherwise) specifies a path for the single-property driver variable type like this, then Blender would crash. This commit introduces two convenience functions - RNA_path_resolve_property() and RNA_path_resolve_property_full() - which mirror/wrap the existing RNA_path_resolve() functions. The only difference though is that these include a check to ensure that what was found from resolving the path was in fact a property (they only return true iff this is the case), and make it explicitly clear in the name that this is what they will do so that there's no further confusion. It is possible to do without these wrapper functions by doing these checks inline, but the few cases that had been patched already were pretty hideous looking specimens. Using these just make it clearer and simpler for all. I've also beefed up the docs on these a bit, and changed these to using bools.
Diffstat (limited to 'source/blender/blenkernel/intern/anim_sys.c')
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 9cdb35586ce..48d83652f56 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -550,7 +550,7 @@ void BKE_animdata_separate_by_basepath(ID *srcID, ID *dstID, ListBase *basepaths
/* Path Validation -------------------------------------------- */
/* Check if a given RNA Path is valid, by tracing it from the given ID, and seeing if we can resolve it */
-static short check_rna_path_is_valid(ID *owner_id, const char *path)
+static bool check_rna_path_is_valid(ID *owner_id, const char *path)
{
PointerRNA id_ptr, ptr;
PropertyRNA *prop = NULL;
@@ -559,7 +559,7 @@ static short check_rna_path_is_valid(ID *owner_id, const char *path)
RNA_id_pointer_create(owner_id, &id_ptr);
/* try to resolve */
- return RNA_path_resolve(&id_ptr, path, &ptr, &prop);
+ return RNA_path_resolve_property(&id_ptr, path, &ptr, &prop);
}
/* Check if some given RNA Path needs fixing - free the given path and set a new one as appropriate
@@ -1164,7 +1164,7 @@ static short animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_in
//printf("%p %s %i %f\n", ptr, path, array_index, value);
/* get property to write to */
- if (RNA_path_resolve(ptr, path, &new_ptr, &prop)) {
+ if (RNA_path_resolve_property(ptr, path, &new_ptr, &prop)) {
/* set value - only for animatable numerical values */
if (RNA_property_animateable(&new_ptr, prop)) {
int array_len = RNA_property_array_length(&new_ptr, prop);
@@ -1650,7 +1650,7 @@ static NlaEvalChannel *nlaevalchan_verify(PointerRNA *ptr, ListBase *channels, N
/* free_path = */ /* UNUSED */ animsys_remap_path(strip->remap, fcu->rna_path, &path);
/* a valid property must be available, and it must be animatable */
- if (RNA_path_resolve(ptr, path, &new_ptr, &prop) == 0) {
+ if (RNA_path_resolve_property(ptr, path, &new_ptr, &prop) == false) {
if (G.debug & G_DEBUG) printf("NLA Strip Eval: Cannot resolve path\n");
return NULL;
}