tests/multi-stage: Clean up child stages
Do not leave them around: force a destroy() on any child stage left when the main loop quits.
This commit is contained in:
parent
169df02a56
commit
24c311466c
@ -3,6 +3,7 @@
|
|||||||
#undef CLUTTER_DISABLE_DEPRECATED
|
#undef CLUTTER_DISABLE_DEPRECATED
|
||||||
#include <clutter/clutter.h>
|
#include <clutter/clutter.h>
|
||||||
|
|
||||||
|
static GList *stages = NULL;
|
||||||
static gint n_stages = 1;
|
static gint n_stages = 1;
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -15,6 +16,12 @@ tex_button_cb (ClutterActor *actor,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_destroy (ClutterActor *actor)
|
||||||
|
{
|
||||||
|
stages = g_list_remove (stages, actor);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
on_button_press (ClutterActor *actor,
|
on_button_press (ClutterActor *actor,
|
||||||
ClutterEvent *event,
|
ClutterEvent *event,
|
||||||
@ -35,6 +42,8 @@ on_button_press (ClutterActor *actor,
|
|||||||
clutter_stage_set_color (CLUTTER_STAGE (new_stage), CLUTTER_COLOR_DarkScarletRed);
|
clutter_stage_set_color (CLUTTER_STAGE (new_stage), CLUTTER_COLOR_DarkScarletRed);
|
||||||
clutter_actor_set_size (new_stage, 320, 240);
|
clutter_actor_set_size (new_stage, 320, 240);
|
||||||
|
|
||||||
|
g_signal_connect (new_stage, "destroy", G_CALLBACK (on_destroy), NULL);
|
||||||
|
|
||||||
tex = clutter_texture_new_from_file (TESTS_DATADIR
|
tex = clutter_texture_new_from_file (TESTS_DATADIR
|
||||||
G_DIR_SEPARATOR_S
|
G_DIR_SEPARATOR_S
|
||||||
"redhand.png",
|
"redhand.png",
|
||||||
@ -91,6 +100,8 @@ on_button_press (ClutterActor *actor,
|
|||||||
|
|
||||||
clutter_actor_show_all (new_stage);
|
clutter_actor_show_all (new_stage);
|
||||||
|
|
||||||
|
stages = g_list_prepend (stages, new_stage);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,5 +138,8 @@ test_multistage_main (int argc, char *argv[])
|
|||||||
|
|
||||||
clutter_main ();
|
clutter_main ();
|
||||||
|
|
||||||
|
g_list_foreach (stages, (GFunc) clutter_actor_destroy, NULL);
|
||||||
|
g_list_free (stages);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user