forked from bartvdbraak/blender
Fix for RNA struct registration: the bpy_class_validate function would only check the immediate functions/properties of the pointer struct type, but not potential base structs. Now it first validates the base struct recursively before the actual properties of the registered class.
Does not have any effect for current registerable types (Operator, Menu, Panel, etc.), since none of those actually have a base struct, but will be required for future types with an actual hierarchy (custom nodes).
This commit is contained in:
parent
23c4026c3f
commit
dee1d86e65
@ -6736,20 +6736,24 @@ static int rna_function_arg_count(FunctionRNA *func)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_function)
|
static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, void *py_data, int *have_function)
|
||||||
{
|
{
|
||||||
const ListBase *lb;
|
const ListBase *lb;
|
||||||
Link *link;
|
Link *link;
|
||||||
FunctionRNA *func;
|
FunctionRNA *func;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
StructRNA *srna = dummyptr->type;
|
|
||||||
const char *class_type = RNA_struct_identifier(srna);
|
const char *class_type = RNA_struct_identifier(srna);
|
||||||
|
StructRNA *srna_base = RNA_struct_base(srna);
|
||||||
PyObject *py_class = (PyObject *)py_data;
|
PyObject *py_class = (PyObject *)py_data;
|
||||||
PyObject *base_class = RNA_struct_py_type_get(srna);
|
PyObject *base_class = RNA_struct_py_type_get(srna);
|
||||||
PyObject *item;
|
PyObject *item;
|
||||||
int i, flag, arg_count, func_arg_count;
|
int i, flag, arg_count, func_arg_count;
|
||||||
const char *py_class_name = ((PyTypeObject *)py_class)->tp_name; // __name__
|
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)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (base_class) {
|
if (base_class) {
|
||||||
if (!PyObject_IsSubclass(py_class, base_class)) {
|
if (!PyObject_IsSubclass(py_class, base_class)) {
|
||||||
@ -6884,6 +6888,11 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO - multiple return values like with rna functions */
|
/* TODO - multiple return values like with rna functions */
|
||||||
static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms)
|
static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user