diff options
author | Dalai Felinto <dalai@blender.org> | 2020-11-18 04:03:02 +0300 |
---|---|---|
committer | Dalai Felinto <dalai@blender.org> | 2020-11-18 04:03:02 +0300 |
commit | 15c6390960e6c9f2c92b1045359c2603851f7438 (patch) | |
tree | 04f66fa8e43281e43f7960e7ac29ab2d1f555646 /source/blender/makesrna/intern | |
parent | 083cde0b43f606f31021c3381e01654214454b24 (diff) | |
parent | 3e325c35f8701eb222a45326c04d54b24e5f23d3 (diff) |
Merge remote-tracking branch 'origin/master' into geometry-nodes
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_animation.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 32 |
2 files changed, 26 insertions, 8 deletions
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index a50d27a726b..0a9f2ff4819 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -1160,7 +1160,7 @@ static void rna_api_animdata_nla_tracks(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_pointer_funcs( prop, "rna_NlaTrack_active_get", "rna_NlaTrack_active_set", NULL, NULL); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Active Constraint", "Active Object constraint"); + RNA_def_property_ui_text(prop, "Active Track", "Active NLA Track"); /* XXX: should (but doesn't) update the active track in the NLA window */ RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL); } diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 1b0a2fca0ce..8cc4f545ca9 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -1812,8 +1812,9 @@ void RNA_def_property_struct_type(PropertyRNA *prop, const char *type) } } -void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type) +void RNA_def_property_struct_runtime(StructOrFunctionRNA *cont, PropertyRNA *prop, StructRNA *type) { + /* Never valid when defined from python. */ StructRNA *srna = DefRNA.laststruct; if (DefRNA.preprocess) { @@ -1821,11 +1822,26 @@ void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type) return; } + const bool is_id_type = (type->flag & STRUCT_ID) != 0; + switch (prop->type) { case PROP_POINTER: { PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop; pprop->type = type; + /* Check between `cont` and `srna` is mandatory, since when defined from python + * `DefRNA.laststruct` is not valid. + * This is not an issue as bpy code already checks for this case on its own. */ + if (cont == srna && (srna->flag & STRUCT_NO_DATABLOCK_IDPROPERTIES) != 0 && is_id_type) { + CLOG_ERROR(&LOG, + "\"%s.%s\", this struct type (probably an Operator, Keymap or UserPreference) " + "does not accept ID pointer properties.", + CONTAINER_RNA_ID(cont), + prop->identifier); + DefRNA.error = true; + return; + } + if (type && (type->flag & STRUCT_ID_REFCOUNT)) { prop->flag |= PROP_ID_REFCOUNT; } @@ -1838,13 +1854,15 @@ void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type) break; } default: - CLOG_ERROR( - &LOG, "\"%s.%s\", invalid type for struct type.", srna->identifier, prop->identifier); + CLOG_ERROR(&LOG, + "\"%s.%s\", invalid type for struct type.", + CONTAINER_RNA_ID(cont), + prop->identifier); DefRNA.error = true; - break; + return; } - if ((type->flag & STRUCT_ID) != 0) { + if (is_id_type) { prop->flag |= PROP_PTR_NO_OWNERSHIP; } } @@ -4144,7 +4162,7 @@ PropertyRNA *RNA_def_pointer_runtime(StructOrFunctionRNA *cont_, PropertyRNA *prop; prop = RNA_def_property(cont, identifier, PROP_POINTER, PROP_NONE); - RNA_def_property_struct_runtime(prop, type); + RNA_def_property_struct_runtime(cont, prop, type); if ((type->flag & STRUCT_ID) != 0) { prop->flag |= PROP_EDITABLE; } @@ -4179,7 +4197,7 @@ PropertyRNA *RNA_def_collection_runtime(StructOrFunctionRNA *cont_, PropertyRNA *prop; prop = RNA_def_property(cont, identifier, PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_runtime(prop, type); + RNA_def_property_struct_runtime(cont, prop, type); RNA_def_property_ui_text(prop, ui_name, ui_description); return prop; |