diff options
author | Jacques Lucke <jacques@blender.org> | 2021-09-06 18:40:53 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-09-06 18:41:15 +0300 |
commit | 4b091f2eb69545b7ebced304b44fc197a7c2aa57 (patch) | |
tree | ce48647d44abde6f5e51fbb1b9f50c4969f24e98 | |
parent | e70f9b0d0eb9e7e55310741a08a1d2002963b829 (diff) |
add comments for anonymous attributes
-rw-r--r-- | source/blender/blenkernel/BKE_geometry_set.hh | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anonymous_attribute.cc | 10 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_customdata_types.h | 4 |
3 files changed, 16 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index d9da4b9fb01..dd921d0d373 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -628,6 +628,10 @@ class AttributeFieldInput : public fn::FieldInput { class AnonymousAttributeFieldInput : public fn::FieldInput { private: + /** + * A strong reference is required to make sure that the referenced attribute is not removed + * automatically. + */ StrongAnonymousAttributeID anonymous_id_; public: diff --git a/source/blender/blenkernel/intern/anonymous_attribute.cc b/source/blender/blenkernel/intern/anonymous_attribute.cc index 73e2a656a7f..67611053d83 100644 --- a/source/blender/blenkernel/intern/anonymous_attribute.cc +++ b/source/blender/blenkernel/intern/anonymous_attribute.cc @@ -18,10 +18,18 @@ using namespace blender::bke; +/** + * A struct that identifies an attribute. It's lifetime is managed by an atomic reference count. + * + * Additionally, this struct can be strongly or weakly owned. The difference is that strong + * ownership means that attributes with this id will be kept around. Weak ownership just makes sure + * that the struct itself stays alive, but corresponding attributes might still be removed + * automatically. + */ struct AnonymousAttributeID { /** * Total number of references to this attribute id. Once this reaches zero, the struct can be - * freed. + * freed. This includes strong and weak references. */ mutable std::atomic<int> refcount_tot = 0; diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h index 214b514b25c..6acea8da15f 100644 --- a/source/blender/makesdna/DNA_customdata_types.h +++ b/source/blender/makesdna/DNA_customdata_types.h @@ -57,7 +57,9 @@ typedef struct CustomDataLayer { void *data; /** * Run-time identifier for this layer. If no one has a strong reference to this id anymore, - * the layer can be removed. + * the layer can be removed. The custom data layer only has a weak reference to the id, because + * otherwise there will always be a strong reference and the attribute can't be removed + * automatically. */ const struct AnonymousAttributeID *anonymous_id; } CustomDataLayer; |