RNA: add option to enable by default lib overridale flag of defined properties.

Similar to the one allowing to deactivate DNA check, etc.

Will helps reduce verbosity when making many new properties overridable.

Note that pointer properties always remain non-overridable by default,
since basically only ID pointers should be.

Reviewed By: brecht

Maniphest Tasks: T77083

Differential Revision: https://developer.blender.org/D7906
This commit is contained in:
Bastien Montagne 2020-06-03 10:37:46 +02:00 committed by Bastien Montagne
parent 0e14eb7b31
commit 3384bb2c66
Notes: blender-bot 2023-02-14 03:13:26 +01:00
Referenced by issue #77083, Library Overrides Constraint and Modifier Access
3 changed files with 21 additions and 0 deletions

View File

@ -50,6 +50,7 @@ void RNA_free(BlenderRNA *brna);
void RNA_define_verify_sdna(bool verify);
void RNA_define_animate_sdna(bool animate);
void RNA_define_fallback_property_update(int noteflag, const char *updatefunc);
void RNA_define_lib_overridable(const bool make_overridable);
void RNA_init(void);
void RNA_exit(void);

View File

@ -71,6 +71,7 @@ BlenderDefRNA DefRNA = {
.preprocess = false,
.verify = true,
.animate = true,
.make_overridable = false,
};
#ifndef RNA_RUNTIME
@ -755,6 +756,15 @@ void RNA_define_verify_sdna(bool verify)
DefRNA.verify = verify;
}
/**
* Properties defined when this is enabled are lib-overridable by default (except for Pointer
* ones).
*/
void RNA_define_lib_overridable(const bool make_overridable)
{
DefRNA.make_overridable = make_overridable;
}
#ifndef RNA_RUNTIME
void RNA_define_animate_sdna(bool animate)
{
@ -1414,6 +1424,14 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_,
}
}
#ifndef RNA_RUNTIME
if (type != PROP_POINTER) {
if (DefRNA.make_overridable) {
prop->flag_override |= PROPOVERRIDE_OVERRIDABLE_LIBRARY;
}
}
#endif
if (type == PROP_STRING) {
/* used so generated 'get/length/set' functions skip a NULL check
* in some cases we want it */

View File

@ -123,6 +123,8 @@ typedef struct BlenderDefRNA {
bool preprocess;
bool verify;
bool animate;
/** Whether RNA properties defined should be overridable or not by default. */
bool make_overridable;
/* Keep last. */
#ifndef RNA_RUNTIME