From 63a74d091111e7c8e2fcf362fbe67de56a339fd8 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 10 Sep 2021 12:59:29 -0600 Subject: [PATCH] Canvas: improve behavior of Widget::compute_bounding_box() Firstly, ::compute_bounding_box() cannot allocate space, so do not try to do that here. Secondly, if there is no allocation yet, use the CairoWidget's own size_request() --- libs/canvas/widget.cc | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/libs/canvas/widget.cc b/libs/canvas/widget.cc index bb33796528..85db46e3ba 100644 --- a/libs/canvas/widget.cc +++ b/libs/canvas/widget.cc @@ -124,20 +124,13 @@ Widget::_size_allocate (Rect const & r) void Widget::compute_bounding_box () const { - GtkRequisition req = { 0, 0 }; - Gtk::Allocation alloc; - - _widget.size_request (req); - - _bounding_box = Rect (0, 0, req.width, req.height); - - /* make sure the widget knows that it got what it asked for */ - alloc.set_x (0); - alloc.set_y (0); - alloc.set_width (req.width); - alloc.set_height (req.height); - - _widget.size_allocate (alloc); + if (_allocation) { + _bounding_box = Rect (0, 0, _allocation.width(), _allocation.height()); + } else { + GtkRequisition req = { 0, 0 }; + _widget.size_request (req); + _bounding_box = Rect (0., 0., req.width, req.height); + } bb_clean (); }