mirror of https://github.com/GNOME/gimp.git
libgimpwidgets: do not free the GtkAdjustment when finalizing...
... GimpMemsizeEntry. A GtkAdjustment is a GInitiallyUnowned, which means it is created as a floating reference. GtkSpinButton assumes its ownership by calling g_object_ref_sink() in gtk_spin_button_new() implementation. Thus it will take care of freeing it and when we try to unref it in finalize(), the object already doesn't exist. Alternatively we could keep another ref (by calling g_object_ref_sink() ourselves) but since the spin button is a child of the entry, it will live all the way until the entry is freed. There is no need to increment the references. So instead, simplify the code, and don't try to free an object we don't own anymore. This fixes CRITICAL assertions: > g_object_unref: assertion 'G_IS_OBJECT (object)' failed
This commit is contained in:
parent
50bcc8db3c
commit
792b27afe1
|
@ -59,6 +59,7 @@ struct _GimpMemsizeEntryPrivate
|
|||
|
||||
guint shift;
|
||||
|
||||
/* adjustement is owned by spinbutton. Do not unref() it. */
|
||||
GtkAdjustment *adjustment;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *menu;
|
||||
|
@ -67,8 +68,6 @@ struct _GimpMemsizeEntryPrivate
|
|||
#define GET_PRIVATE(obj) (((GimpMemsizeEntry *) (obj))->priv)
|
||||
|
||||
|
||||
static void gimp_memsize_entry_finalize (GObject *object);
|
||||
|
||||
static void gimp_memsize_entry_adj_callback (GtkAdjustment *adj,
|
||||
GimpMemsizeEntry *entry);
|
||||
static void gimp_memsize_entry_unit_callback (GtkWidget *widget,
|
||||
|
@ -87,8 +86,6 @@ gimp_memsize_entry_class_init (GimpMemsizeEntryClass *klass)
|
|||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gimp_memsize_entry_finalize;
|
||||
|
||||
klass->value_changed = NULL;
|
||||
|
||||
gimp_memsize_entry_signals[VALUE_CHANGED] =
|
||||
|
@ -116,16 +113,6 @@ gimp_memsize_entry_init (GimpMemsizeEntry *entry)
|
|||
gtk_box_set_spacing (GTK_BOX (entry), 4);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_memsize_entry_finalize (GObject *object)
|
||||
{
|
||||
GimpMemsizeEntryPrivate *private = GET_PRIVATE (object);
|
||||
|
||||
g_clear_object (&private->adjustment);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_memsize_entry_adj_callback (GtkAdjustment *adj,
|
||||
GimpMemsizeEntry *entry)
|
||||
|
|
Loading…
Reference in New Issue