diff options
author | Hans Goudey <h.goudey@me.com> | 2021-09-06 20:24:21 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-09-06 20:24:21 +0300 |
commit | d53e400454bba48a0f2d2a58e008f993d0c469be (patch) | |
tree | ccc96312f8a4fcfd155ff8808e4694eaabe7d21f | |
parent | 64d1fe34502ea7fb33a95b0d55bc2b52aba12184 (diff) | |
parent | 4b091f2eb69545b7ebced304b44fc197a7c2aa57 (diff) |
Merge branch 'temp-geometry-nodes-fields' of git.blender.org:blender into temp-geometry-nodes-fields
-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; |