[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59993] trunk/blender/source/blender/ makesrna/intern/makesrna.c: 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.

Lukas Toenne lukas.toenne at googlemail.com
Tue Sep 10 10:27:13 CEST 2013


Revision: 59993
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59993
Author:   lukastoenne
Date:     2013-09-10 08:27:13 +0000 (Tue, 10 Sep 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/makesrna.c

Modified: trunk/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/makesrna.c	2013-09-10 08:24:42 UTC (rev 59992)
+++ trunk/blender/source/blender/makesrna/intern/makesrna.c	2013-09-10 08:27:13 UTC (rev 59993)
@@ -3545,8 +3545,12 @@
 "	} \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 @@
 "	} \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"




More information about the Bf-blender-cvs mailing list