listbase: Don't warn on scroll in empty list
authorBenjamin Otte <otte@redhat.com>
Thu, 20 Apr 2023 17:07:08 +0000 (19:07 +0200)
committerBenjamin Otte <otte@redhat.com>
Thu, 20 Apr 2023 21:33:28 +0000 (23:33 +0200)
Empty lists can still be scrolled if the scroll happens in the same
frame as the emptying of the list.

Related: #5763

gtk/gtklistbase.c

index 0c7df53aa0ef9964c420952a67c1a8ee2e89427b..0a7dbb0b025d7080dd67783cddf409c31bda774c 100644 (file)
@@ -214,6 +214,11 @@ gtk_list_base_adjustment_value_changed_cb (GtkAdjustment *adjustment,
                                                    &pos,
                                                    &cell_area))
     {
+      /* If we get here with n-items == 0, then somebody cleared the list but
+       * GC hasn't run. So no item to be found. */
+      if (gtk_list_base_get_n_items (self) == 0)
+        return;
+
       g_warning ("%s failed to scroll to given position. Ignoring...", G_OBJECT_TYPE_NAME (self));
       return;
     }