Fix layer heights cache to use layer_data id

Updated the caching logic in SimulationView to use the id of the layer_data object instead of the node. This ensures the cache is correctly invalidated when layer_data changes, preventing potential issues when nodes are reused.
This commit is contained in:
HellAholic 2025-12-14 23:54:32 +01:00
parent 749d81c4d9
commit f5a9cb2f65

View file

@ -309,14 +309,15 @@ class SimulationView(CuraView):
if not layer_data:
continue
# Check if we already have cached data for this node
current_node_id = id(node)
if self._layer_heights_cache_node_id == current_node_id and self._layer_heights_cache:
# Check if we already have cached data for this layer_data object
# Use id of the layer_data itself, not the node, since node might be reused
current_layer_data_id = id(layer_data)
if self._layer_heights_cache_node_id == current_layer_data_id and self._layer_heights_cache:
# Cache is still valid, no need to recalculate
return
# Cache is invalid or empty, recalculate
self._layer_heights_cache.clear()
self._layer_heights_cache_node_id = current_node_id
self._layer_heights_cache_node_id = current_layer_data_id
has_gcode_decorator = node.getDecorator(GCodeListDecorator) is not None