diff options
author | Hans Goudey <h.goudey@me.com> | 2021-08-05 18:46:12 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-08-05 18:46:12 +0300 |
commit | c41c3784285e960e7edb451283e5774a7fa6570f (patch) | |
tree | 3812d9b4ac70a110fc11417af377444b6158df3b /source/blender/makesrna/intern/rna_access.c | |
parent | 1cf574dc39b9f10ba7cd43625c28d86d3cdbe0dc (diff) | |
parent | bd44e82b255a231242a1b7ddd59cee7830af20ea (diff) |
Merge branch 'master' into refactor-idprop-ui-data
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 462f24c6170..c820398dc1b 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -36,6 +36,7 @@ #include "BLI_dynstr.h" #include "BLI_ghash.h" #include "BLI_math.h" +#include "BLI_threads.h" #include "BLI_utildefines.h" #include "BLF_api.h" @@ -3512,6 +3513,8 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop) PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop; IDProperty *idprop; + static ThreadMutex lock = BLI_MUTEX_INITIALIZER; + BLI_assert(RNA_property_type(prop) == PROP_POINTER); if ((idprop = rna_idproperty_check(&prop, ptr))) { @@ -3531,9 +3534,14 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop) return pprop->get(ptr); } if (prop->flag & PROP_IDPROPERTY) { - /* XXX temporary hack to add it automatically, reading should - * never do any write ops, to ensure thread safety etc. */ + /* NOTE: While creating/writing data in an accessor is really bad design-wise, this is + * currently very difficult to avoid in that case. So a global mutex is used to keep ensuring + * thread safety. */ + BLI_mutex_lock(&lock); + /* NOTE: We do not need to check again for existence of the pointer after locking here, since + * this is also done in #RNA_property_pointer_add itself. */ RNA_property_pointer_add(ptr, prop); + BLI_mutex_unlock(&lock); return RNA_property_pointer_get(ptr, prop); } return PointerRNA_NULL; @@ -6559,7 +6567,7 @@ bool RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, bool return RNA_property_is_set_ex(ptr, prop, use_ghost); } /* python raises an error */ - /* printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); */ + // printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); return 0; } @@ -6571,7 +6579,7 @@ bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier) return RNA_property_is_set(ptr, prop); } /* python raises an error */ - /* printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); */ + // printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); return 0; } |