[virt-tools-list] [PATCH virt-viewer 06/12] kiosk: ref_sink the toolbar

Marc-André Lureau marcandre.lureau at gmail.com
Fri Aug 16 11:04:57 UTC 2013


On Thu, Aug 15, 2013 at 4:40 PM, Daniel P. Berrange <berrange at redhat.com> wrote:
> On Mon, Jul 15, 2013 at 09:36:13PM +0200, Marc-André Lureau wrote:
>> Removes a warning when adding/removing the gtk widget dynamically.
>
> Can you explain why we need this ? What gtk rule were we violating
> by not having it ?

Since we replace the toolbar with another widget, we can't keep a weak
reference on it. And doing g_object_ref() immediately after creation
of a gtk widget was emiting a floating reference warning at some
point. Unfortunately I can't reproduce it now. I will change it to
ref(), and unref() in dispose.

>> ---
>>  src/virt-viewer-window.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
>> index d0e6357..69e50b8 100644
>> --- a/src/virt-viewer-window.c
>> +++ b/src/virt-viewer-window.c
>> @@ -928,7 +928,7 @@ virt_viewer_window_toolbar_setup(VirtViewerWindow *self)
>>      GtkWidget *button;
>>      VirtViewerWindowPrivate *priv = self->priv;
>>
>> -    priv->toolbar = gtk_toolbar_new();
>> +    priv->toolbar = g_object_ref_sink (gtk_toolbar_new());
>>      gtk_toolbar_set_show_arrow(GTK_TOOLBAR(priv->toolbar), FALSE);
>>      gtk_widget_set_no_show_all(priv->toolbar, TRUE);
>>      gtk_toolbar_set_style(GTK_TOOLBAR(priv->toolbar), GTK_TOOLBAR_BOTH_HORIZ);
>
>
> Daniel
> --
> |: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
> |: http://libvirt.org              -o-             http://virt-manager.org :|
> |: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
> |: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|



-- 
Marc-André Lureau




More information about the virt-tools-list mailing list