Re: GtkLabel strong refs the mnemonic widget



Owen Taylor <otaylor redhat com> writes:

> [ Bug reference: http://bugzilla.gnome.org/show_bug.cgi?id=93334 ]
> 
> Another compatibility question. Right now:
> 
>  GtkWidget *button = gtk_button_new_with_mnemonic ("_Push Me");
>  g_object_ref (button);
>  gtk_object_sink (GTK_OBJECT (button);
> 
>  gtk_container_add (container, button);
>  gtk_container_remove (container, button);
> 
>  g_object_unref (button);
> 
> Leaks the button and contained label. This is because 
> gtk_label_set_mnemonic_widget() makes a strong reference
> on the label, so you get a reference loop between the
> button and the label.
> 
> The obvious fix for this would be to make the reference
> a weak reference instead. That, however, is strictly
> speaking an incompatible change, because code like:
> 
>  GtkLabel *label = gtk_label_new ("Foo');
>  GtkWidget *entry = gtk_entry_new ();
> 
>  g_object_ref (entry);
>  gtk_object_sink (GTK_OBJECT (entry));
>  
>  gtk_label_set_mnemonic_widget (label, entry);
>  g_object_unref (entry);
> 
>  [...]
> 
>  entry = g_object_ref (gtk_label_get_mnemonic_widget (label));
> 
> Woudl no longer work. I think that this is "acceptable breakage - 
> I really doubt people use the mnemonic widget property as
> the only reference to a widget, but one can always be
> suprised...

I've gone ahead and made this change (fingers crossed...)

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]