[Bf-blender-cvs] [f66e146] id-remap: Attempt to fix RNA nightmare with ListBase used as Collection return type for functions.

Bastien Montagne noreply at git.blender.org
Thu Nov 26 15:44:17 CET 2015


Commit: f66e14611d4dc2492e39a23f2deac89b5c9a7887
Author: Bastien Montagne
Date:   Thu Nov 26 15:26:05 2015 +0100
Branches: id-remap
https://developer.blender.org/rBf66e14611d4dc2492e39a23f2deac89b5c9a7887

Attempt to fix RNA nightmare with ListBase used as Collection return type for functions.

This is hacky to make work on Linux, and seems to totally break on Windows.

So now, instead, we define a CollectionListBase (exact copy of ListBase), to be used inside RNA...

Seems to work nicely on Linux, lets see what win buildbot says.

===================================================================

M	source/blender/makesrna/RNA_types.h
M	source/blender/makesrna/intern/makesrna.c
M	source/blender/makesrna/intern/rna_ID.c
M	source/blender/python/intern/bpy_rna.c

===================================================================

diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 04a2361..a302bc6 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -285,6 +285,11 @@ typedef struct CollectionPointerLink {
 	PointerRNA ptr;
 } CollectionPointerLink;
 
+/* Copy of ListBase for RNA... */
+typedef struct CollectionListBase {
+	struct CollectionPointerLink *first, *last;
+} CollectionListBase;
+
 typedef enum RawPropertyType {
 	PROP_RAW_UNSET = -1,
 	PROP_RAW_INT, // XXX - abused for types that are not set, eg. MFace.verts, needs fixing.
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 1167758..9c31f42 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -466,7 +466,7 @@ static const char *rna_parameter_type_name(PropertyRNA *parm)
 		}
 		case PROP_COLLECTION:
 		{
-			return "ListBase";
+			return "CollectionListBase";
 		}
 		default:
 			return "<error, no type specified>";
@@ -3853,8 +3853,6 @@ static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f)
 	fprintf(f, "#include \"RNA_types.h\"\n");
 	fprintf(f, "#include \"RNA_access.h\"\n");
 
-	fprintf(f, "#include \"DNA_listBase.h\"\n");
-
 	fprintf(f, "%s", cpp_classes);
 
 	fprintf(f, "/**************** Declarations ****************/\n\n");
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index a131392..8d47ea3 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -341,7 +341,7 @@ static void rna_ID_user_remap(ID *id, Main *bmain, ID *new_id)
 	}
 }
 
-static ListBase rna_ID_used_by_ids(ID *id, Main *bmain)
+static CollectionListBase rna_ID_used_by_ids(ID *id, Main *bmain)
 {
 	ListBase ret = {0};
 	struct IDUsersIter *iter = BKE_library_ID_users_iter_init(bmain, id);
@@ -359,7 +359,8 @@ static ListBase rna_ID_used_by_ids(ID *id, Main *bmain)
 
 	BKE_library_ID_users_iter_end(&iter);
 
-	return ret;
+	/* CollectionListBase is a mere RNA redefinition of ListBase. */
+	return *(CollectionListBase *)&ret;
 }
 
 static AnimData * rna_ID_animation_data_create(ID *id, Main *bmain)
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 220ec5b..c720a10 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -4988,7 +4988,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
 			}
 			case PROP_COLLECTION:
 			{
-				ListBase *lb = (ListBase *)data;
+				CollectionListBase *lb = (CollectionListBase *)data;
 				CollectionPointerLink *link;
 
 				ret = PyList_New(0);




More information about the Bf-blender-cvs mailing list