GObject parent_instance;
TreeNode *node; /* NULL when the row has been destroyed */
+ gpointer item;
};
struct _GtkTreeListRowClass
{
node->row = g_object_new (GTK_TYPE_TREE_LIST_ROW, NULL);
node->row->node = node;
+ node->row->item = g_object_ref (node->item);
return node->row;
}
g_object_notify_by_pspec (G_OBJECT (self), row_properties[ROW_PROP_DEPTH]);
g_object_notify_by_pspec (G_OBJECT (self), row_properties[ROW_PROP_EXPANDABLE]);
g_object_notify_by_pspec (G_OBJECT (self), row_properties[ROW_PROP_EXPANDED]);
- g_object_notify_by_pspec (G_OBJECT (self), row_properties[ROW_PROP_ITEM]);
self->node = NULL;
g_object_thaw_notify (G_OBJECT (self));
if (self->node)
self->node->row = NULL;
+ g_clear_object (&self->item);
+
G_OBJECT_CLASS (gtk_tree_list_row_parent_class)->dispose (object);
}
*
* Gets the item corresponding to this row,
*
- * The value returned by this function never changes until the
- * row is destroyed.
- *
* Returns: (nullable) (type GObject) (transfer full): The item
- * of this row or %NULL when the row was destroyed
+ * of this row. This function is only marked as nullable for backwards
+ * compatibility reasons.
*/
gpointer
gtk_tree_list_row_get_item (GtkTreeListRow *self)
{
g_return_val_if_fail (GTK_IS_TREE_LIST_ROW (self), NULL);
- if (self->node == NULL)
- return NULL;
-
- return g_object_ref (self->node->item);
+ return g_object_ref (self->item);
}
/**
if ((pspec->flags & G_PARAM_READABLE) == 0)
continue;
+ /* This is set by the treelistmodel, plain
+ * g_object_new() will crash here */
+ if (g_type_is_a (type, GTK_TYPE_TREE_LIST_ROW) &&
+ (strcmp (pspec->name, "item") == 0))
+ continue;
+
/* This is set via class_init, and we have a11y tests to verify it */
if (g_type_is_a (type, GTK_TYPE_ACCESSIBLE) &&
strcmp (pspec->name, "accessible-role") == 0)