From 05a41aaa61593a6fbc7d6e7ffde2b62b9f1e1d20 Mon Sep 17 00:00:00 2001 From: Evgeny Voevodin Date: Wed, 11 Jul 2012 14:09:23 +0400 Subject: [PATCH] tizen/src/maru_sdl.c: Fix improper operations with SDL surfaces. The bug is that vga_hw_update() invokes dpy_update() where qemu_ds_update() is called. qemu_ds_update() sends a signal to thread run_qemu_update() waiting to be released and to invoke qemu_update(). After this happens there are two ways possible: 1. run_qemu_update() is released, got mutex and qemu_update() is called. Simultaneously qemu_ds_refresh() is waiting on the mutex to perform SDL_SetVideoMode(). This is most common way. 2. If we unlucky, vga_hw_update() returns and qemu_ds_refresh() gets mutex before run_qemu_update() is released. In this way SDL_SetVideoMode() is called before qemu_update() is invoked. This leads qemu_update() to operate on invalidated surface_qemu. So, to solve this problem we can add a flag indicating that qemu_update() finished it's work and that we free to invoke SDL_SetVideoMode(). Or we can simply move vga_hw_update() invocation after SDL_SetVideoMode() call. We chose the second variant as more efficient. Signed-off-by: Evgeny Voevodin --- tizen/src/maru_sdl.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tizen/src/maru_sdl.c b/tizen/src/maru_sdl.c index 91720a0..83d6c0a 100644 --- a/tizen/src/maru_sdl.c +++ b/tizen/src/maru_sdl.c @@ -225,8 +225,6 @@ static void qemu_ds_refresh(DisplayState *ds) { SDL_Event ev1, *ev = &ev1; - vga_hw_update(); - // surface may be NULL in init func. qemu_display_surface = ds->surface; @@ -259,10 +257,7 @@ static void qemu_ds_refresh(DisplayState *ds) } pthread_mutex_lock(&sdl_mutex); -#ifndef TARGET_ARM - /* FIXME: For some reason quit should be called here for x86*/ - SDL_Quit(); //The returned surface is freed by SDL_Quit and must not be freed by the caller -#endif + surface_screen = SDL_SetVideoMode(w, h, SDL_BPP, SDL_FLAGS); if (surface_screen == NULL) { ERR("Could not open SDL display (%dx%dx%d): %s\n", w, h, SDL_BPP, SDL_GetError()); @@ -282,6 +277,8 @@ static void qemu_ds_refresh(DisplayState *ds) } } + vga_hw_update(); + #ifdef TARGET_ARM #ifdef SDL_THREAD pthread_mutex_lock(&sdl_mutex); -- 2.7.4