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 <e.voevodin@samsung.com>
{
SDL_Event ev1, *ev = &ev1;
- vga_hw_update();
-
// surface may be NULL in init func.
qemu_display_surface = ds->surface;
}
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());
}
}
+ vga_hw_update();
+
#ifdef TARGET_ARM
#ifdef SDL_THREAD
pthread_mutex_lock(&sdl_mutex);