`throttle tree update` problem
Created by: Durman
Problem statement
Throttle context manager undo eachother.
with throttle_tree_update():
tree.links.new()
with throttle_tree_update():
tree.links.new()
tree.links.new() # <- this will triger update
It has matter during importing node tree when whole tree should be created without updates. It is similar to next situation. Electrician is switching off electricity before doing his work. But if electricity was already switched off it would be quite careless to the electrician switched it on because possibly there is another electrcian which is stll worcking some where.
Possible solution is to make only first context manager responsible for unfreezing tree.
@contextmanager
def throttle_tree_update(node):
has_changed_status = False
if not node.id_data.skip_tree_update:
node.id_data.skip_tree_update = True
has_changed_status = True
try:
yield node
finally:
if has_changed_status:
node.id_data.skip_tree_update = False