listbase: Clear any newly set adjustments
authorBenjamin Otte <otte@redhat.com>
Thu, 30 Mar 2023 06:29:32 +0000 (08:29 +0200)
committerBenjamin Otte <otte@redhat.com>
Fri, 31 Mar 2023 15:35:48 +0000 (17:35 +0200)
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().

gtk/gtklistbase.c

index c0e24482791f7ddc8617bbffbab62b4a256f7790..0c7df53aa0ef9964c420952a67c1a8ee2e89427b 100644 (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);