From e0baf24b4aa87f70b6bf08a1d578a31ad94ee0cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 11 May 2023 11:42:17 +0400 Subject: [PATCH] ui/sdl2: fix surface_gl_update_texture: Assertion 'gls' failed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before sdl2_gl_update() is called, sdl2_gl_switch() may decide to destroy the console window and its associated shaders. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1644 Fixes: c84ab0a500a8 ("ui/console: optionally update after gfx switch") Signed-off-by: Marc-André Lureau Tested-by: Bin Meng Message-Id: <20230511074217.4171842-1-marcandre.lureau@redhat.com> (cherry picked from commit b3a654d82ecf276b59a67b2fd688e11a0d8a0064) Signed-off-by: Michael Tokarev --- ui/sdl2-gl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index 39cab8cde737..bbfa70eac30e 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -67,6 +67,10 @@ void sdl2_gl_update(DisplayChangeListener *dcl, assert(scon->opengl); + if (!scon->real_window) { + return; + } + SDL_GL_MakeCurrent(scon->real_window, scon->winctx); surface_gl_update_texture(scon->gls, scon->surface, x, y, w, h); scon->updates++;