4.6.0 Infinite loop inside GtkBoxLayout distribute_remaining_size()
Steps to reproduce
- Add a custom widget to a gtk box that increases one dimension relative to its opposite dimension (in my case, an image that increases its height based on the allocated width, appended to a vertical box)
- observe infinite loop inside distribute_remaining_size()
example c++ code :
Gtk::SizeRequestMode custom_widget::get_request_mode_vfunc() const
{
return Gtk::SizeRequestMode::WIDTH_FOR_HEIGHT;
}
static int s_aspect_ratio = 2;
void custom_widget::measure_vfunc(Gtk::Orientation orientation, int for_size, int& minimum, int& natural, int&, int&) const
{
if (orientation == Gtk::Orientation::VERTICAL)
{
minimum = natural = for_size / s_aspect_ratio;
}
}
Current behavior
Program enters infinite loop
Expected outcome
Program does not enter infinite loop
Version information
using GTK 4.6.0, problem was not observed in 4.4.0
Notes
- program repeatadly displays
Gtk-CRITICAL **: 12:14:28.196: gtk_widget_measure: assertion 'for_size >= -1' failed
- !4151 (closed) removes the error but infinite loop is still observed.
- from looking at the gtk code, it appears as if boxes assume that expanding a child in one direction will cause it to shrink in the other, which is not the case for my custom widget. If this use case is not supported, is there any supported way to grow a widget while maintaining aspect ratio?
Edited by Timm Bäder