From 220eb45ef0a9c7e506b1058082853646e1f618f1 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Wed, 12 Jun 2013 13:20:15 +0200 Subject: [PATCH] GtkListBox: Protect against reentrancy. Activating a row may destroy the widget, so keep a ref since we're doing thing to the listbox after emission. --- gtk/gtklistbox.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c index 6a77699494..bd9a852b94 100644 --- a/gtk/gtklistbox.c +++ b/gtk/gtklistbox.c @@ -1233,24 +1233,30 @@ gtk_list_box_real_button_release_event (GtkWidget *widget, GtkListBox *list_box = GTK_LIST_BOX (widget); GtkListBoxPrivate *priv = list_box->priv; + /* Take a ref to protect against reentrancy (i.e. the activation may destroy the widget) */ + g_object_ref (list_box); + if (event->button == GDK_BUTTON_PRIMARY) { if (priv->active_row != NULL && priv->active_row_active) { + gtk_widget_unset_state_flags (GTK_WIDGET (priv->active_row), + GTK_STATE_FLAG_ACTIVE); + if (priv->activate_single_click) gtk_list_box_select_and_activate (list_box, priv->active_row); else gtk_list_box_update_selected (list_box, priv->active_row); - gtk_widget_unset_state_flags (GTK_WIDGET (priv->active_row), - GTK_STATE_FLAG_ACTIVE); } priv->active_row = NULL; priv->active_row_active = FALSE; gtk_widget_queue_draw (GTK_WIDGET (list_box)); } + g_object_unref (list_box); + return FALSE; }