From 27bdc96dc97ee416a5d59c2c3155cbe6fdf00207 Mon Sep 17 00:00:00 2001 From: Cyril Hrubis Date: Mon, 18 Jun 2012 01:56:25 +0200 Subject: [PATCH] spiv: Stop loader thread before resizing backend buffer. --- demos/spiv/spiv.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index 19f6d561..489188ef 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -419,21 +419,26 @@ static void *image_loader(void *ptr) static pthread_t loader_thread = (pthread_t)0; -static void show_image(struct loader_params *params, const char *path) +static void stop_loader(void) { - int ret; - - /* stop previous loader thread */ if (loader_thread) { abort_flag = 1; pthread_join(loader_thread, NULL); loader_thread = (pthread_t)0; abort_flag = 0; } - +} + +static void show_image(struct loader_params *params, const char *path) +{ + int ret; + if (path != NULL) params->img_path = path; + /* stop previous loader thread */ + stop_loader(); + ret = pthread_create(&loader_thread, NULL, image_loader, (void*)params); if (ret) { @@ -795,6 +800,8 @@ int main(int argc, char *argv[]) case GP_EV_SYS: switch (ev.code) { case GP_EV_SYS_RESIZE: + /* stop loader thread before resizing backend buffer */ + stop_loader(); GP_BackendResize(backend, ev.val.sys.w, ev.val.sys.h); GP_Fill(backend->context, 0); params.show_progress_once = 1; -- 2.11.4.GIT