Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-08-31 16:32:21 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-08-31 16:49:50 +0300
commit636baa598a5698d84eca89d17c67a74092cef4d0 (patch)
tree6c09f62384fd8a75698a73ec409c5139512025df /source/blender/makesrna/intern/rna_define.c
parent018137f76248ab85bbe2057ca5d67c55a559247b (diff)
RNA: Limit which classes struct-map contains
Only add subclasses of: Menu, Panel, Header, UIList, Operator This helps avoid unnecessary naming collisions, See T52599 for details
Diffstat (limited to 'source/blender/makesrna/intern/rna_define.c')
-rw-r--r--source/blender/makesrna/intern/rna_define.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index cbe9684e821..2a6a3d06b15 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -142,7 +142,9 @@ static void rna_brna_structs_add(BlenderRNA *brna, StructRNA *srna)
/* This exception is only needed for pre-processing.
* otherwise we don't allow empty names. */
- if (srna->identifier[0] != '\0') {
+ if ((srna->flag & STRUCT_PUBLIC_NAMESPACE) &&
+ (srna->identifier[0] != '\0'))
+ {
BLI_ghash_insert(brna->structs_map, (void *)srna->identifier, srna);
}
}
@@ -150,7 +152,7 @@ static void rna_brna_structs_add(BlenderRNA *brna, StructRNA *srna)
#ifdef RNA_RUNTIME
static void rna_brna_structs_remove_and_free(BlenderRNA *brna, StructRNA *srna)
{
- if (brna->structs_map) {
+ if ((srna->flag & STRUCT_PUBLIC_NAMESPACE) && brna->structs_map) {
if (srna->identifier[0] != '\0') {
BLI_ghash_remove(brna->structs_map, (void *)srna->identifier, NULL, NULL);
}
@@ -763,12 +765,19 @@ StructRNA *RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRN
BLI_listbase_clear(&srna->functions);
srna->py_type = NULL;
+ srna->base = srnafrom;
+
if (DefRNA.preprocess) {
- srna->base = srnafrom;
dsfrom = rna_find_def_struct(srnafrom);
}
- else
- srna->base = srnafrom;
+ else {
+ if (srnafrom->flag & STRUCT_PUBLIC_NAMESPACE_INHERIT) {
+ srna->flag |= STRUCT_PUBLIC_NAMESPACE | STRUCT_PUBLIC_NAMESPACE_INHERIT;
+ }
+ else {
+ srna->flag &= ~(STRUCT_PUBLIC_NAMESPACE | STRUCT_PUBLIC_NAMESPACE_INHERIT);
+ }
+ }
}
srna->identifier = identifier;
@@ -780,6 +789,10 @@ StructRNA *RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRN
if (!srnafrom)
srna->icon = ICON_DOT;
+ if (DefRNA.preprocess) {
+ srna->flag |= STRUCT_PUBLIC_NAMESPACE;
+ }
+
rna_brna_structs_add(brna, srna);
if (DefRNA.preprocess) {
@@ -1001,12 +1014,14 @@ void RNA_def_struct_identifier(BlenderRNA *brna, StructRNA *srna, const char *id
}
/* Operator registration may set twice, see: operator_properties_init */
- if (identifier != srna->identifier) {
- if (srna->identifier[0] != '\0') {
- BLI_ghash_remove(brna->structs_map, (void *)srna->identifier, NULL, NULL);
- }
- if (identifier[0] != '\0') {
- BLI_ghash_insert(brna->structs_map, (void *)identifier, srna);
+ if (srna->flag & STRUCT_PUBLIC_NAMESPACE) {
+ if (identifier != srna->identifier) {
+ if (srna->identifier[0] != '\0') {
+ BLI_ghash_remove(brna->structs_map, (void *)srna->identifier, NULL, NULL);
+ }
+ if (identifier[0] != '\0') {
+ BLI_ghash_insert(brna->structs_map, (void *)identifier, srna);
+ }
}
}
@@ -3316,8 +3331,10 @@ void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void RNA_def_struct_duplicate_pointers(BlenderRNA *brna, StructRNA *srna)
{
if (srna->identifier) {
- srna->identifier = BLI_strdup(srna->identifier);
- BLI_ghash_replace_key(brna->structs_map, (void *)srna->identifier);
+ if (srna->flag & STRUCT_PUBLIC_NAMESPACE) {
+ srna->identifier = BLI_strdup(srna->identifier);
+ BLI_ghash_replace_key(brna->structs_map, (void *)srna->identifier);
+ }
}
if (srna->name) {
srna->name = BLI_strdup(srna->name);
@@ -3333,8 +3350,10 @@ void RNA_def_struct_free_pointers(BlenderRNA *brna, StructRNA *srna)
{
if (srna->flag & STRUCT_FREE_POINTERS) {
if (srna->identifier) {
- if (brna != NULL) {
- BLI_ghash_remove(brna->structs_map, (void *)srna->identifier, NULL, NULL);
+ if (srna->flag & STRUCT_PUBLIC_NAMESPACE) {
+ if (brna != NULL) {
+ BLI_ghash_remove(brna->structs_map, (void *)srna->identifier, NULL, NULL);
+ }
}
MEM_freeN((void *)srna->identifier);
}