fix recursion error

This commit is contained in:
Nicolas Predella 2026-05-16 19:18:03 +03:00
parent 6174dbce4a
commit a672043385
2 changed files with 8 additions and 4 deletions

View file

@ -5,6 +5,8 @@ from . import tree
def notify_tree_changed(self, context):
from . import tree
if tree._is_updating:
return
tree._tree_changed = True
node = None

View file

@ -12,9 +12,11 @@ if TYPE_CHECKING:
def get_referenced_objects(node, visited=None):
if visited is None:
visited = set()
if node in visited:
ptr = node.as_pointer()
if ptr in visited:
return set()
visited.add(node)
visited.add(ptr)
objs = set()
# Check all input sockets for objects
@ -42,7 +44,7 @@ _is_updating = False
_tree_changed = False
def tree_update_handler(scene, depsgraph):
global _tree_changed
global _tree_changed, _is_updating
# Names of objects that have changed
updated_object_names = {update.id.name for update in depsgraph.updates if isinstance(update.id, bpy.types.Object)}
@ -51,7 +53,7 @@ def tree_update_handler(scene, depsgraph):
updated_meshes = {update.id.name for update in depsgraph.updates if isinstance(update.id, bpy.types.Mesh)}
if updated_meshes:
for obj in bpy.data.objects:
if obj.type == 'MESH' and obj.data in updated_meshes:
if obj.type == 'MESH' and obj.data.name in updated_meshes:
updated_object_names.add(obj.name)
# Note: custom NodeTree updates often don't appear in depsgraph.updates