From dd857e2a1db6116c0725576b88ed14df6d925f70 Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Wed, 1 Jan 2025 23:41:59 +0100 Subject: [PATCH] GesturePropertyTransition: Only call done_callback if the transition finished --- src/Gestures/GesturePropertyTransition.vala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Gestures/GesturePropertyTransition.vala b/src/Gestures/GesturePropertyTransition.vala index 673bfcf96..0281a3964 100644 --- a/src/Gestures/GesturePropertyTransition.vala +++ b/src/Gestures/GesturePropertyTransition.vala @@ -84,7 +84,10 @@ public class Gala.GesturePropertyTransition : Object { * to the final position. If with_gesture is false it will just ease to the {@link to_value}. * #this will keep itself alive until the animation finishes so it is safe to immediatly unref it after creation and calling start. * - * @param done_callback a callback for when the transition finishes. It is guaranteed to be called exactly once. + * @param done_callback a callback for when the transition finishes. This shouldn't be used for setting state, instead state should + * be set immediately on {@link GestureTracker.OnEnd} not only once the animation ends to allow for interrupting the animation by starting a new gesture. + * done_callback will only be called if the animation finishes, not if it is interrupted e.g. by starting a new animation for the same property, + * destroying the actor or removing the transition. */ public void start (bool with_gesture, owned DoneCallback? done_callback = null) { ref (); @@ -179,8 +182,8 @@ public class Gala.GesturePropertyTransition : Object { } } - private void finish () { - if (done_callback != null) { + private void finish (bool callback = true) { + if (done_callback != null && callback) { done_callback (); }