From f38d4458f7bb0727332448eb4ed86b17a4725a35 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Wed, 13 Nov 2019 15:50:51 +0200 Subject: [PATCH] tests: remove static data from presentation While get_presentation() will only ever be called once (making the caching of the return value moot), it is good to stop using the static variable as it would cause surprising problems if anyone adds more tests here and runs it under the new test harness. It was leaked before and continues to be so. Signed-off-by: Pekka Paalanen --- tests/presentation-test.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/presentation-test.c b/tests/presentation-test.c index f6ffe480..a4f8c87f 100644 --- a/tests/presentation-test.c +++ b/tests/presentation-test.c @@ -43,10 +43,7 @@ get_presentation(struct client *client) { struct global *g; struct global *global_pres = NULL; - static struct wp_presentation *pres; - - if (pres) - return pres; + struct wp_presentation *pres; wl_list_for_each(g, &client->global_list, link) { if (strcmp(g->interface, wp_presentation_interface.name)) @@ -137,13 +134,15 @@ static const struct wp_presentation_feedback_listener feedback_listener = { }; static struct feedback * -feedback_create(struct client *client, struct wl_surface *surface) +feedback_create(struct client *client, + struct wl_surface *surface, + struct wp_presentation *pres) { struct feedback *fb; fb = xzalloc(sizeof *fb); fb->client = client; - fb->obj = wp_presentation_feedback(get_presentation(client), surface); + fb->obj = wp_presentation_feedback(pres, surface); wp_presentation_feedback_add_listener(fb->obj, &feedback_listener, fb); return fb; @@ -215,13 +214,15 @@ TEST(test_presentation_feedback_simple) { struct client *client; struct feedback *fb; + struct wp_presentation *pres; client = create_client_and_test_surface(100, 50, 123, 77); assert(client); + pres = get_presentation(client); wl_surface_attach(client->surface->wl_surface, client->surface->buffer->proxy, 0, 0); - fb = feedback_create(client, client->surface->wl_surface); + fb = feedback_create(client, client->surface->wl_surface, pres); wl_surface_damage(client->surface->wl_surface, 0, 0, 100, 100); wl_surface_commit(client->surface->wl_surface);