Skip to content

Commit bd3eb37

Browse files
authored
Merge branch 'main' into leolost/gesture-controller-test-finalize
2 parents 30d6eb7 + ce44fdf commit bd3eb37

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

lib/Gestures/GestureController.vala

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public class Gala.GestureController : Object {
133133
running = true;
134134
}
135135

136-
timeline = null;
136+
remove_timeline ();
137137
}
138138

139139
private bool gesture_detected (GestureBackend backend, Gesture gesture, uint32 timestamp) {
@@ -268,19 +268,36 @@ public class Gala.GestureController : Object {
268268
}
269269

270270
var spring = new SpringTimeline (target.actor, progress, clamped_to, velocity, 1, 1, 500);
271-
spring.progress.connect ((value) => progress = value);
272-
spring.stopped.connect_after (finished);
271+
spring.progress.connect (on_timeline_progress);
272+
spring.stopped.connect_after (on_timeline_stopped);
273273

274274
timeline = spring;
275275

276276
target.propagate (COMMIT, action, clamped_to);
277277
}
278278

279-
private void finished (bool is_finished = true) requires (is_finished) {
279+
private void on_timeline_progress (double value) {
280+
progress = value;
281+
}
282+
283+
private void on_timeline_stopped (bool is_finished) {
284+
assert (is_finished);
285+
finished ();
286+
}
287+
288+
private void finished () {
280289
assert (running);
281290
target.propagate (END, action, progress);
282291
running = false;
283-
timeline = null;
292+
remove_timeline ();
293+
}
294+
295+
private void remove_timeline () {
296+
if (timeline != null) {
297+
timeline.progress.disconnect (on_timeline_progress);
298+
timeline.stopped.disconnect (on_timeline_stopped);
299+
timeline = null;
300+
}
284301
}
285302

286303
/**

0 commit comments

Comments
 (0)