ui/console: fix crash when using gl context with non-gl listeners
The commit7cc712e98
("ui: dispatch GL events to all listener") mechanically replaced the dpy_gl calls with a dispatch loop, using the same pre-conditions. However, it didn't take into account that all listeners do not have to implement the GL callbacks. Add the missing pre-conditions before calling the callbacks. Fix crash when running a GL-enabled VM with "-device virtio-gpu-gl-pci -display egl-headless -vnc :0". Fixes:7cc712e98
("ui: dispatch GL events to all listener") Reported-by: Akihiko Odaki <akihiko.odaki@gmail.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20220214201337.1814787-2-marcandre.lureau@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
0a2a40da4f
commit
a9fbce5e94
@ -1860,8 +1860,10 @@ void dpy_gl_scanout_disable(QemuConsole *con)
|
|||||||
con->scanout.kind = SCANOUT_NONE;
|
con->scanout.kind = SCANOUT_NONE;
|
||||||
}
|
}
|
||||||
QLIST_FOREACH(dcl, &s->listeners, next) {
|
QLIST_FOREACH(dcl, &s->listeners, next) {
|
||||||
|
if (dcl->ops->dpy_gl_scanout_disable) {
|
||||||
dcl->ops->dpy_gl_scanout_disable(dcl);
|
dcl->ops->dpy_gl_scanout_disable(dcl);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dpy_gl_scanout_texture(QemuConsole *con,
|
void dpy_gl_scanout_texture(QemuConsole *con,
|
||||||
@ -1881,11 +1883,13 @@ void dpy_gl_scanout_texture(QemuConsole *con,
|
|||||||
x, y, width, height
|
x, y, width, height
|
||||||
};
|
};
|
||||||
QLIST_FOREACH(dcl, &s->listeners, next) {
|
QLIST_FOREACH(dcl, &s->listeners, next) {
|
||||||
|
if (dcl->ops->dpy_gl_scanout_texture) {
|
||||||
dcl->ops->dpy_gl_scanout_texture(dcl, backing_id,
|
dcl->ops->dpy_gl_scanout_texture(dcl, backing_id,
|
||||||
backing_y_0_top,
|
backing_y_0_top,
|
||||||
backing_width, backing_height,
|
backing_width, backing_height,
|
||||||
x, y, width, height);
|
x, y, width, height);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dpy_gl_scanout_dmabuf(QemuConsole *con,
|
void dpy_gl_scanout_dmabuf(QemuConsole *con,
|
||||||
@ -1897,8 +1901,10 @@ void dpy_gl_scanout_dmabuf(QemuConsole *con,
|
|||||||
con->scanout.kind = SCANOUT_DMABUF;
|
con->scanout.kind = SCANOUT_DMABUF;
|
||||||
con->scanout.dmabuf = dmabuf;
|
con->scanout.dmabuf = dmabuf;
|
||||||
QLIST_FOREACH(dcl, &s->listeners, next) {
|
QLIST_FOREACH(dcl, &s->listeners, next) {
|
||||||
|
if (dcl->ops->dpy_gl_scanout_dmabuf) {
|
||||||
dcl->ops->dpy_gl_scanout_dmabuf(dcl, dmabuf);
|
dcl->ops->dpy_gl_scanout_dmabuf(dcl, dmabuf);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf,
|
void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf,
|
||||||
@ -1951,8 +1957,10 @@ void dpy_gl_update(QemuConsole *con,
|
|||||||
|
|
||||||
graphic_hw_gl_block(con, true);
|
graphic_hw_gl_block(con, true);
|
||||||
QLIST_FOREACH(dcl, &s->listeners, next) {
|
QLIST_FOREACH(dcl, &s->listeners, next) {
|
||||||
|
if (dcl->ops->dpy_gl_update) {
|
||||||
dcl->ops->dpy_gl_update(dcl, x, y, w, h);
|
dcl->ops->dpy_gl_update(dcl, x, y, w, h);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
graphic_hw_gl_block(con, false);
|
graphic_hw_gl_block(con, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user