diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-09-10 12:27:13 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-09-10 12:27:13 +0400 |
commit | 4e9145fa1cbe3a24457fb94c29fa167d41c5d273 (patch) | |
tree | 653f91a2350a576f6ff0672e3587bfb9f387b058 /source/blender | |
parent | 5dbe17cc125bf7d9e96b45c02bdfbd00b6103bdf (diff) |
makesrna fix: The C++ wrapper functions for collection lookup (both int and string) were not clearing the return pointer if no item is found, but only in case there is a custom lookup function defined.
This causes trouble with Cycles because the C++ API uses the returned pointer to determine validity - if no item is found the pointer should be NULL for checking.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 4703e70b369..838f8a33f07 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -3545,8 +3545,12 @@ static const char *cpp_classes = "" " } \n" "#define COLLECTION_PROPERTY_LOOKUP_INT_TRUE(sname, identifier) \\\n" " inline static int sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, PointerRNA *r_ptr) \\\n" -" { return sname##_##identifier##_lookup_int(ptr, key, r_ptr); } \n" -"\n" +" { \\\n" +" int found = sname##_##identifier##_lookup_int(ptr, key, r_ptr); \\\n" +" if (!found) \\\n" +" memset(r_ptr, 0, sizeof(*r_ptr)); \\\n" +" return found; \\\n" +" } \n" "#define COLLECTION_PROPERTY_LOOKUP_STRING_FALSE(sname, identifier) \\\n" " inline static int sname##_##identifier##_lookup_string_wrap(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) \\\n" " { \\\n" @@ -3574,8 +3578,12 @@ static const char *cpp_classes = "" " } \n" "#define COLLECTION_PROPERTY_LOOKUP_STRING_TRUE(sname, identifier) \\\n" " inline static int sname##_##identifier##_lookup_string_wrap(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) \\\n" -" { return sname##_##identifier##_lookup_string(ptr, key, r_ptr); } \n" -"\n" +" { \\\n" +" int found = sname##_##identifier##_lookup_string(ptr, key, r_ptr); \\\n" +" if (!found) \\\n" +" memset(r_ptr, 0, sizeof(*r_ptr)); \\\n" +" return found; \\\n" +" } \n" "#define COLLECTION_PROPERTY(collection_funcs, type, sname, identifier, has_length, has_lookup_int, has_lookup_string) \\\n" " typedef CollectionIterator<type, sname##_##identifier##_begin, \\\n" " sname##_##identifier##_next, sname##_##identifier##_end> identifier##_iterator; \\\n" |