From 4f50c68296fdc321f42e4c19661969627ba51c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 6 Feb 2018 11:49:23 +0100 Subject: [PATCH] cellrendereraccel: unref sizing_label --- gtk/gtkcellrendereraccel.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcellrendereraccel.c b/gtk/gtkcellrendereraccel.c index 5c6784588d..ab9e1c4d86 100644 --- a/gtk/gtkcellrendereraccel.c +++ b/gtk/gtkcellrendereraccel.c @@ -112,6 +112,16 @@ gtk_cell_renderer_accel_init (GtkCellRendererAccel *cell_accel) g_free (text); } +static void +gtk_cell_renderer_accel_dispose (GObject *object) +{ + GtkCellRendererAccelPrivate *priv = GTK_CELL_RENDERER_ACCEL (object)->priv; + + g_clear_object (&priv->sizing_label); + + G_OBJECT_CLASS (gtk_cell_renderer_accel_parent_class)->dispose (object); +} + static void gtk_cell_renderer_accel_class_init (GtkCellRendererAccelClass *cell_accel_class) { @@ -123,6 +133,7 @@ gtk_cell_renderer_accel_class_init (GtkCellRendererAccelClass *cell_accel_class) object_class->set_property = gtk_cell_renderer_accel_set_property; object_class->get_property = gtk_cell_renderer_accel_get_property; + object_class->dispose = gtk_cell_renderer_accel_dispose; cell_renderer_class->get_preferred_width = gtk_cell_renderer_accel_get_preferred_width; cell_renderer_class->start_editing = gtk_cell_renderer_accel_start_editing; @@ -396,7 +407,10 @@ gtk_cell_renderer_accel_get_preferred_width (GtkCellRenderer *cell, GtkRequisition min_req, nat_req; if (priv->sizing_label == NULL) - priv->sizing_label = gtk_label_new (_("New accelerator…")); + { + priv->sizing_label = gtk_label_new (_("New accelerator…")); + g_object_ref_sink (priv->sizing_label); + } gtk_widget_get_preferred_size (priv->sizing_label, &min_req, &nat_req);