@samitouri / QOSamiQemu / commits / c141bcb6af

ui/gtk-egl: Ensure EGL surface is available before drawing

The EGL surface and context are destroyed when a new GTK window is created. We must ensure these are recreated and initialized before any rendering happens in gd_egl_refresh. Currently, the check for a pending draw is performed before the surface initialization block. This can result in an attempt to draw when the EGL surface (vc->gfx.esurface) is not yet available. This patch moves the drawing check after the surface initialization to ensure a valid surface exists before rendering in gd_egl_refresh. Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com> Signed-off-by: Dongwon Kim <dongwon.kim@intel.com> Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20260303011151.1925827-1-dongwon.kim@intel.com>

Dongwon Kim committed Mar 2, 2026 at 17:11 UTC c141bcb6afaa73c72cb368bedbf3b36e97d68d1a
1 file changed +6 -6
ui/gtk-egl.c
+6 -6
@@ -152,12 +152,6 @@ void gd_egl_refresh(DisplayChangeListener *dcl)
152 gd_update_monitor_refresh_rate(
153 vc, vc->window ? vc->window : vc->gfx.drawing_area);
154
155 - if (vc->gfx.guest_fb.dmabuf &&
156 - qemu_dmabuf_get_draw_submitted(vc->gfx.guest_fb.dmabuf)) {
157 - gd_egl_draw(vc);
158 - return;
159 - }
160 -
155 if (!vc->gfx.esurface) {
156 gd_egl_init(vc);
157 if (!vc->gfx.esurface) {
@@ -176,6 +170,12 @@ void gd_egl_refresh(DisplayChangeListener *dcl)
170 #endif
171 }
172
173 + if (vc->gfx.guest_fb.dmabuf &&
174 + qemu_dmabuf_get_draw_submitted(vc->gfx.guest_fb.dmabuf)) {
175 + gd_egl_draw(vc);
176 + return;
177 + }
178 +
179 graphic_hw_update(dcl->con);
180
181 if (vc->gfx.glupdates) {