Fix crashes on ARM due to window-size overflow

On Intel systems ArdourCanvas::COORD_MAX (1.7e+307) was rounded
to (gint) -2147483648. gtk+ treats negative window size-requests
as 1px.

However on ARM, COORD_MAX was truncated to +2147483648, gtk+ limits
this to 65535. Most WM/Xwin systems cannot handle windows this large.
It also exceeds the max size of cairo [image] surfaces.

This issue was introduced in a1c67b4ad7
when "natural_size" was removed. Before that change infinitely large
canvas had a natural_size of 2x2 px.
This commit is contained in:
Robin Gareus 2022-03-09 21:13:27 +01:00
parent 4048bcc6b6
commit 9e75235912
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -1559,7 +1559,18 @@ GtkCanvasViewport::on_size_request (Gtk::Requisition* req)
_canvas.root()->size_request (width, height);
_canvas.request_size (Duple (width, height));
req->width = width;
req->height = height;
}
/* special case ArdourCanvas::COORD_MAX (really: no size constraint),
* also limit to cairo constraints determined by coordinates of things
* sent to pixman being in 16.16 format. */
if (width > 32767) {
width = 0;
}
if (height > 32767) {
height = 0;
}
req->width = std::max<int>(1, width);
req->height = std::max<int>(1, height);
}