From f35df3a3ccb84bdcb58d0830bdc4df01f454fa9c Mon Sep 17 00:00:00 2001
From: Tommi Komulainen <tommi.komulainen@iki.fi>
Date: Sun, 30 Mar 2008 16:28:38 +0300
Subject: [PATCH] test-multistage: stop and destroy the timeline when stage is destroyed

When the stage gets destroyed, the actors go along with it. However the
timeline is left running, and the behaviour keeps trying to update
destroyed objects.

This is essentially a stop gap solution to stop the test from breaking.
However the real solution should be something more thought out handling
of stage/actors destruction. For example
 * timelines/behaviours would be tied to a stage and when the stage
   goes, so do all related timelines
 * behaviours follow the destruction of actors and when no actors are
 * left alive, the behaviour/timeline is destroyed/stopped as well
---
 clutter/tests/test-multistage.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/clutter/tests/test-multistage.c b/clutter/tests/test-multistage.c
index ac6e7fe..5017492 100644
--- a/clutter/tests/test-multistage.c
+++ b/clutter/tests/test-multistage.c
@@ -11,6 +11,13 @@ tex_button_cb (ClutterActor    *actor,
 }
 
 static void
+stage_destroy_cb (ClutterTimeline *timeline)
+{
+  clutter_timeline_stop (timeline);
+  g_object_unref (timeline);
+}
+
+static void
 on_button_press (ClutterActor *actor,
                  ClutterEvent *event,
                  gpointer      data)
@@ -89,6 +96,8 @@ on_button_press (ClutterActor *actor,
   clutter_behaviour_apply (r_behave, label);
   clutter_timeline_start (timeline);
 
+  g_signal_connect_swapped (new_stage, "destroy", G_CALLBACK (stage_destroy_cb), timeline);
+
   clutter_actor_show_all (new_stage);
 }
 
-- 
1.5.4.4

