mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 14:00:09 +00:00
columnview: Make sure cells disconnect from their column
When a cell is removed from the columnview, we need to make sure it s not just removed from the cell (via unset_parent()) but also from the column. Previously, we were doing this from dispose(), but this is broken because dispose() only runs when the refcount goes to zero. But if some code still has a reference for whatever reason, this won't happen. So now we do it explicitly together with unset_parent().
This commit is contained in:
parent
323adf9aa8
commit
3c451b3ec7
@ -269,11 +269,12 @@ gtk_column_view_cell_widget_size_allocate (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_column_view_cell_widget_dispose (GObject *object)
|
||||
/* This should be to be called when unsetting the parent, but we have no
|
||||
* set_parent vfunc().
|
||||
*/
|
||||
void
|
||||
gtk_column_view_cell_widget_unset_column (GtkColumnViewCellWidget *self)
|
||||
{
|
||||
GtkColumnViewCellWidget *self = GTK_COLUMN_VIEW_CELL_WIDGET (object);
|
||||
|
||||
if (self->column)
|
||||
{
|
||||
gtk_column_view_column_remove_cell (self->column, self);
|
||||
@ -288,6 +289,15 @@ gtk_column_view_cell_widget_dispose (GObject *object)
|
||||
|
||||
g_clear_object (&self->column);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_column_view_cell_widget_dispose (GObject *object)
|
||||
{
|
||||
GtkColumnViewCellWidget *self = GTK_COLUMN_VIEW_CELL_WIDGET (object);
|
||||
|
||||
/* unset_parent() forgot to call this. Be very angry. */
|
||||
g_warn_if_fail (self->column == NULL);
|
||||
|
||||
G_OBJECT_CLASS (gtk_column_view_cell_widget_parent_class)->dispose (object);
|
||||
}
|
||||
|
@ -46,5 +46,6 @@ void gtk_column_view_cell_widget_remove (
|
||||
GtkColumnViewCellWidget * gtk_column_view_cell_widget_get_next (GtkColumnViewCellWidget *self);
|
||||
GtkColumnViewCellWidget * gtk_column_view_cell_widget_get_prev (GtkColumnViewCellWidget *self);
|
||||
GtkColumnViewColumn * gtk_column_view_cell_widget_get_column (GtkColumnViewCellWidget *self);
|
||||
void gtk_column_view_cell_widget_unset_column (GtkColumnViewCellWidget *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -592,6 +592,9 @@ void
|
||||
gtk_column_view_row_widget_remove_child (GtkColumnViewRowWidget *self,
|
||||
GtkWidget *child)
|
||||
{
|
||||
if (GTK_IS_COLUMN_VIEW_CELL_WIDGET (child))
|
||||
gtk_column_view_cell_widget_unset_column (GTK_COLUMN_VIEW_CELL_WIDGET (child));
|
||||
|
||||
gtk_widget_unparent (child);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user