[Bf-blender-cvs] [3694a7b] object_nodes: Fix for registering RNA classes with registered parent functions.

Lukas Tönne noreply at git.blender.org
Tue Nov 24 09:42:32 CET 2015


Commit: 3694a7bdfc65f37a7c8b998f7de5396be83dff21
Author: Lukas Tönne
Date:   Fri Jul 17 15:16:40 2015 +0200
Branches: object_nodes
https://developer.blender.org/rB3694a7bdfc65f37a7c8b998f7de5396be83dff21

Fix for registering RNA classes with registered parent functions.

The recursive registration for functions uses a simple int array for
flagging found functions. This is shared with the parent, so any child
functions will overwrite parent function flags for the same index
(this is not overloading).

The patch now requires using a larger array that can accomodate all
registerable functions from parents and children. It puts flags for
parents first, then children.

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

M	source/blender/python/intern/bpy_rna.c

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

diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 5414c4e..bd82ed4 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -6944,7 +6944,8 @@ static int rna_function_arg_count(FunctionRNA *func, int *min_count)
 	return count;
 }
 
-static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, void *py_data, int *have_function)
+static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, void *py_data,
+                                        int *have_function, int *have_function_offset)
 {
 	const ListBase *lb;
 	Link *link;
@@ -6955,12 +6956,12 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v
 	PyObject *py_class = (PyObject *)py_data;
 	PyObject *base_class = RNA_struct_py_type_get(srna);
 	PyObject *item;
-	int i, flag, arg_count, func_arg_count, func_arg_min_count = 0;
+	int flag, arg_count, func_arg_count, func_arg_min_count = 0;
 	bool is_staticmethod;
 	const char *py_class_name = ((PyTypeObject *)py_class)->tp_name;  /* __name__ */
 
 	if (srna_base) {
-		if (bpy_class_validate_recursive(dummyptr, srna_base, py_data, have_function) != 0)
+		if (bpy_class_validate_recursive(dummyptr, srna_base, py_data, have_function, have_function_offset) != 0)
 			return -1;
 	}
 
@@ -6975,7 +6976,6 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v
 
 	/* verify callback functions */
 	lb = RNA_struct_type_functions(srna);
-	i = 0;
 	for (link = lb->first; link; link = link->next) {
 		func = (FunctionRNA *)link;
 		flag = RNA_function_flag(func);
@@ -6986,8 +6986,8 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v
 
 		item = PyObject_GetAttrString(py_class, RNA_function_identifier(func));
 
-		have_function[i] = (item != NULL);
-		i++;
+		have_function[*have_function_offset] = (item != NULL);
+		++(*have_function_offset);
 
 		if (item == NULL) {
 			if ((flag & (FUNC_REGISTER_OPTIONAL & ~FUNC_REGISTER)) == 0) {
@@ -7113,7 +7113,8 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v
 
 static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_function)
 {
-	return bpy_class_validate_recursive(dummyptr, dummyptr->type, py_data, have_function);
+	int have_function_offset = 0;
+	return bpy_class_validate_recursive(dummyptr, dummyptr->type, py_data, have_function, &have_function_offset);
 }
 
 /* TODO - multiple return values like with rna functions */




More information about the Bf-blender-cvs mailing list