[Bf-blender-cvs] [4cb8438e08c] master: Geometry Nodes: warn when output attribute has not been saved

Jacques Lucke noreply at git.blender.org
Fri Apr 23 12:45:14 CEST 2021


Commit: 4cb8438e08cb64d755f627c8eeb3e8cda73864f1
Author: Jacques Lucke
Date:   Fri Apr 23 12:44:59 2021 +0200
Branches: master
https://developer.blender.org/rB4cb8438e08cb64d755f627c8eeb3e8cda73864f1

Geometry Nodes: warn when output attribute has not been saved

===================================================================

M	source/blender/blenkernel/BKE_attribute_access.hh
M	source/blender/blenkernel/intern/attribute_access.cc

===================================================================

diff --git a/source/blender/blenkernel/BKE_attribute_access.hh b/source/blender/blenkernel/BKE_attribute_access.hh
index f6a6de04b70..5feae1bf4ca 100644
--- a/source/blender/blenkernel/BKE_attribute_access.hh
+++ b/source/blender/blenkernel/BKE_attribute_access.hh
@@ -94,6 +94,7 @@ class OutputAttribute {
   SaveFn save_;
   std::optional<fn::GVMutableArray_GSpan> optional_span_varray_;
   bool ignore_old_values_ = false;
+  bool save_has_been_called_ = false;
 
  public:
   OutputAttribute() = default;
@@ -109,6 +110,10 @@ class OutputAttribute {
   {
   }
 
+  OutputAttribute(OutputAttribute &&other) = default;
+
+  ~OutputAttribute();
+
   operator bool() const
   {
     return varray_.get() != nullptr;
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 6c37d34dc9b..5b2f588959f 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -184,6 +184,7 @@ AttributeDomain attribute_domain_highest_priority(Span<AttributeDomain> domains)
 
 void OutputAttribute::save()
 {
+  save_has_been_called_ = true;
   if (optional_span_varray_.has_value()) {
     optional_span_varray_->save();
   }
@@ -192,6 +193,15 @@ void OutputAttribute::save()
   }
 }
 
+OutputAttribute::~OutputAttribute()
+{
+  if (!save_has_been_called_) {
+    if (varray_) {
+      std::cout << "Warning: Call `save()` to make sure that changes persist in all cases.\n";
+    }
+  }
+}
+
 GVArrayPtr BuiltinCustomDataLayerProvider::try_get_for_read(
     const GeometryComponent &component) const
 {



More information about the Bf-blender-cvs mailing list