dmabuf: Avoid division by 0

When opening mks for an already running VM, the QEMU dbus backend has no
way to tell to the VM refresh the display and submit a new UpdateDMABuf.

So by the time size_allocate is called, the height and width of the paintable are
still set to 0.

This should fix the size allocate warning we see now until we figure out a proper
fix from the QEMU side.
This commit is contained in:
Bilal Elmoussaoui 2023-08-29 11:41:39 +02:00
parent 9334cd4ee9
commit 4f08953fb0

View File

@ -97,7 +97,10 @@ mks_dmabuf_paintable_get_intrinsic_aspect_ratio (GdkPaintable *paintable)
{ {
MksDmabufPaintable *self = MKS_DMABUF_PAINTABLE (paintable); MksDmabufPaintable *self = MKS_DMABUF_PAINTABLE (paintable);
return (double)self->width / (double)self->height; if (self->height != 0)
return (double)self->width / (double)self->height;
else
return 0.;
} }
static void static void