Web lists-archives.com

Maybe GListModel incorrectness.

I have custom GListModel, which hold a boxed type. And I bound it to GtkListBox. It works, but floods console with

(vala-panel-runner:9452): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

I take a look into gtklistbox.c, and what I found:

static void
gtk_list_box_bound_model_changed (GListModel *list,
                                  guint       position,
                                  guint       removed,
                                  guint       added,
                                  gpointer    user_data)
  GtkListBox *box = user_data;
  GtkListBoxPrivate *priv = BOX_PRIV (user_data);
  guint i;

  while (removed--)
      GtkListBoxRow *row;

      row = gtk_list_box_get_row_at_index (box, position);
      gtk_widget_destroy (GTK_WIDGET (row));

  for (i = 0; i < added; i++)
      GObject *item;
      GtkWidget *widget;

      item = g_list_model_get_item (list, position + i);
      widget = priv->create_widget_func (item, priv->create_widget_func_data);

      /* We allow the create_widget_func to either return a full
       * reference or a floating reference.  If we got the floating
       * reference, then turn it into a full reference now.  That means
       * that gtk_list_box_insert() will take another full reference.
       * Finally, we'll release this full reference below, leaving only
       * the one held by the box.
      if (g_object_is_floating (widget))
        g_object_ref_sink (widget);

      gtk_widget_show (widget);
      gtk_list_box_insert (box, widget, position + i);

      g_object_unref (widget);
      g_object_unref (item); //This is hardcoded g_object_unref!!!!
I found hardcoded g_object_unref, which is not good.

I think GLIstModel must state about items must be GObject subclasses, or implement a boxed type handler of dup and free. (Like GDestroyNotify)

What do you think?
gtk-list mailing list