diff options
author | Jacques Lucke <jacques@blender.org> | 2021-10-29 11:29:38 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-10-29 11:29:50 +0300 |
commit | 7c860ab9d4b54f9c394d3c2769927f55c6737b5f (patch) | |
tree | 90c04e3c037e48e218056da35dd7303ebfd37a39 | |
parent | be0d5da341cf3f33ba2d7cca8c979abf9d94f683 (diff) |
Fix T92499: duplicating geometry nodes modifier causes crash
Calling `remove_unused_references` inside the `modify_geometry_sets` loop
was known to be not entirely reliable before. Now I just moved it out of
the loop which fixes the bug.
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc b/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc index f4a127faf43..1e94a4a6a50 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc @@ -202,12 +202,15 @@ static void geo_node_instance_on_points_exec(GeoNodeExecParams params) instances, *geometry_set.get_component_for_read<CurveComponent>(), instance, params); geometry_set.remove(GEO_COMPONENT_TYPE_CURVE); } - /* Unused references may have been added above. Remove those now so that other nodes don't - * process them needlessly. */ - /** \note: This currently expects that all originally existing instances were used. */ - instances.remove_unused_references(); }); + /* Unused references may have been added above. Remove those now so that other nodes don't + * process them needlessly. + * This should eventually be moved into the loop above, but currently this is quite tricky + * because it might remove references that the loop still wants to iterate over. */ + InstancesComponent &instances = geometry_set.get_component_for_write<InstancesComponent>(); + instances.remove_unused_references(); + params.set_output("Instances", std::move(geometry_set)); } |