RNA: add fallback update function

Use so we can have a default update function,
that doesn't need to be set for every property.
This commit is contained in:
Campbell Barton
2019-05-23 00:29:31 +10:00
parent f309c93f1f
commit 8d20d6b2eb
3 changed files with 25 additions and 0 deletions

View File

@@ -48,6 +48,7 @@ void RNA_define_free(BlenderRNA *brna);
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_init(void);
void RNA_exit(void);

View File

@@ -709,6 +709,14 @@ void RNA_define_animate_sdna(bool animate)
}
#endif
#ifndef RNA_RUNTIME
void RNA_define_fallback_property_update(int noteflag, const char *updatefunc)
{
DefRNA.fallback.property_update.noteflag = noteflag;
DefRNA.fallback.property_update.updatefunc = updatefunc;
}
#endif
void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext)
{
#ifdef RNA_RUNTIME
@@ -1413,6 +1421,12 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_,
}
/* TODO: do we want that for runtime-defined stuff too? Id say no, but... maybe yes :/ */
#ifndef RNA_RUNTIME
/* Both are typically cleared. */
RNA_def_property_update(
prop, DefRNA.fallback.property_update.noteflag, DefRNA.fallback.property_update.updatefunc);
#endif
rna_addtail(&cont->properties, prop);
return prop;

View File

@@ -116,6 +116,16 @@ typedef struct BlenderDefRNA {
ListBase allocs;
struct StructRNA *laststruct;
int error, silent, preprocess, verify, animate;
/* Keep last. */
#ifndef RNA_RUNTIME
struct {
/** #RNA_def_property_update */
struct {
int noteflag;
const char *updatefunc;
} property_update;
} fallback;
#endif
} BlenderDefRNA;
extern BlenderDefRNA DefRNA;