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.
This commit is contained in:
Jacques Lucke 2021-10-29 10:29:38 +02:00
parent be0d5da341
commit 7c860ab9d4
Notes: blender-bot 2023-02-14 03:46:57 +01:00
Referenced by issue #92499, Duplicating geometry nodes modifier causes Blender to crash
1 changed files with 7 additions and 4 deletions

View File

@ -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));
}