From 9c0fa583f526f711cda196f5a287f7fe5438297a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 26 May 2016 22:44:49 +0800 Subject: [PATCH] clutter/tests/conform: Fix actor-offscreen-redirect The actor-offscreen-redirect didn't initialize its state properly, so it could potentially end up with the "was_painted" state being TRUE from the start, effectively skipping the whole test. Fixing so that the test even run resulted in the test getting stuck in a dead lock due to the verification that a frame was drawn was done from a paint callback. A paint callback had the mutex held, so when the test case tried to run the main loop, the next paint callback caller path taken would try to re-lock the same mutex, thus dead lock. https://bugzilla.gnome.org/show_bug.cgi?id=768976 --- .../tests/conform/actor-offscreen-redirect.c | 49 ++++++++++++------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/clutter/tests/conform/actor-offscreen-redirect.c b/clutter/tests/conform/actor-offscreen-redirect.c index f47af3617..63d5e6cfd 100644 --- a/clutter/tests/conform/actor-offscreen-redirect.c +++ b/clutter/tests/conform/actor-offscreen-redirect.c @@ -176,6 +176,33 @@ verify_redraw (Data *data, int expected_paint_count) g_assert_cmpint (data->foo_actor->paint_count, ==, expected_paint_count); } +static gboolean +verify_redraws (gpointer user_data) +{ + Data *data = user_data; + + /* Queueing a redraw on the actor should cause a redraw */ + clutter_actor_queue_redraw (data->container); + verify_redraw (data, 1); + + /* Queueing a redraw on a child should cause a redraw */ + clutter_actor_queue_redraw (data->child); + verify_redraw (data, 1); + + /* Modifying the transformation on the parent should cause a + redraw */ + clutter_actor_set_anchor_point (data->parent_container, 0, 1); + verify_redraw (data, 1); + + /* Redrawing an unrelated actor shouldn't cause a redraw */ + clutter_actor_set_position (data->unrelated_actor, 0, 1); + verify_redraw (data, 0); + + data->was_painted = TRUE; + + return G_SOURCE_REMOVE; +} + static gboolean run_verify (gpointer user_data) { @@ -273,24 +300,8 @@ run_verify (gpointer user_data) 0, 255); - /* Queueing a redraw on the actor should cause a redraw */ - clutter_actor_queue_redraw (data->container); - verify_redraw (data, 1); - - /* Queueing a redraw on a child should cause a redraw */ - clutter_actor_queue_redraw (data->child); - verify_redraw (data, 1); - - /* Modifying the transformation on the parent should cause a - redraw */ - clutter_actor_set_anchor_point (data->parent_container, 0, 1); - verify_redraw (data, 1); - - /* Redrawing an unrelated actor shouldn't cause a redraw */ - clutter_actor_set_position (data->unrelated_actor, 0, 1); - verify_redraw (data, 0); - - data->was_painted = TRUE; + /* Check redraws */ + g_idle_add (verify_redraws, data); return G_SOURCE_REMOVE; } @@ -298,7 +309,7 @@ run_verify (gpointer user_data) static void actor_offscreen_redirect (void) { - Data data; + Data data = { 0 }; if (!cogl_features_available (COGL_FEATURE_OFFSCREEN)) return;