Skip to content

Commit

Permalink
Also cancel tasks when new animation dispatched
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-liang committed Aug 23, 2023
1 parent a459210 commit 743eaee
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions arena/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,17 @@ def update_object(self, obj, **kwargs):
if kwargs:
obj.update_attributes(**kwargs)

# Check if any keys in kwargs are in delayed_prop_tasks, cancel the
# corresponding tasks if so. Maybe faster to iterate on delayed_prop_tasks
# but then we mutate the dict while iterating...
# Check if any keys in delayed_prop_tasks are pending new animations
# and cancel corresponding final update tasks or, if they are in
# kwarg property updates, cancel the task as well as the animation
need_to_run_animations = False
if len(obj.delayed_prop_tasks) > 0:
for anim in obj.animations:
if anim.property in obj.delayed_prop_tasks:
task_to_cancel = obj.delayed_prop_tasks[anim.property]
task_to_cancel.cancel()
del task_to_cancel

for k in kwargs:
if str(k) in obj.delayed_prop_tasks:
need_to_run_animations = True
Expand Down

0 comments on commit 743eaee

Please sign in to comment.