Commit: 5904953d221868ca12b361f7b8f81395440bfb87
Author: Sybren A. Stüvel
Date:   Tue Jul 21 14:10:34 2020 +0200
Branches: master
https://developer.blender.org/rB5904953d221868ca12b361f7b8f81395440bfb87

Tests: IO, fixed a memory leak in the USDHierarchyIteratorTest

No functional changes to Blender.

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

M       source/blender/io/common/intern/abstract_hierarchy_iterator.cc
M       source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc

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

diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc 
b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc
index 8c9245ef9b0..8e66c069e18 100644
--- a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc
@@ -149,6 +149,12 @@ 
AbstractHierarchyIterator::AbstractHierarchyIterator(Depsgraph *depsgraph)
 
 AbstractHierarchyIterator::~AbstractHierarchyIterator()
 {
+  /* release_writers() cannot be called here directly, as it calls into the 
pure-virtual
+   * release_writer() function. By the time this destructor is called, the 
subclass that implements
+   * that pure-virtual function is already destructed. */
+  BLI_assert(
+      writers_.empty() ||
+      !"release_writers() should be called before the 
AbstractHierarchyIterator goes out of scope");
 }
 
 void AbstractHierarchyIterator::iterate_and_write()
diff --git 
a/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc 
b/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc
index ff073416574..2bc7560e177 100644
--- a/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc
+++ b/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc
@@ -71,6 +71,7 @@ class TestingHierarchyIterator : public 
AbstractHierarchyIterator {
   }
   virtual ~TestingHierarchyIterator()
   {
+    release_writers();
   }
 
  protected:

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to