From 4f08953fb07b13b0da86f7abbfd500cc320da9b3 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Tue, 29 Aug 2023 11:41:39 +0200 Subject: [PATCH] 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. --- lib/mks-dmabuf-paintable.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/mks-dmabuf-paintable.c b/lib/mks-dmabuf-paintable.c index b77d9cc..a45dffe 100644 --- a/lib/mks-dmabuf-paintable.c +++ b/lib/mks-dmabuf-paintable.c @@ -97,7 +97,10 @@ mks_dmabuf_paintable_get_intrinsic_aspect_ratio (GdkPaintable *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