listbase: Clear any newly set adjustments

The scrolling code assumes the adjustment values are up to date or
it crashes and before we've run size_allocate() we haven't update them.

Fixes a crash in the gtk-demo scrollinfo that would set the adjustments
with random values (via ScrolledWindow.set_child()) and then scroll in a
tick callback right before the (first) size_allocate().
This commit is contained in:
Benjamin Otte
2023-03-30 08:29:32 +02:00
parent 6f4175345f
commit dbff49b5a7

View File

@@ -731,6 +731,8 @@ gtk_list_base_set_adjustment (GtkListBase *self,
if (adjustment == NULL)
adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
else
gtk_adjustment_configure (adjustment, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
g_object_ref_sink (adjustment);
gtk_list_base_clear_adjustment (self, orientation);