[virt-tools-list] [PATCH virt-viewer 2/2] Remove extra ref on SpiceDisplay

Christophe Fergeau cfergeau at redhat.com
Thu Sep 11 08:48:50 UTC 2014


On Wed, Sep 10, 2014 at 10:52:01PM +0200, Fabiano Fidêncio wrote:
> On Sep 10, 2014 8:42 PM, "Jonathon Jongsma" <jjongsma at redhat.com> wrote:
> >
> > There's no need to ref the SpiceDisplay widget when adding it to a
> > container. The container will take its own ref.
> 
> If we remove the SpiceDisplay from the container, it can unref the last
> reference of the widget. Ack if you are sure that this is not the case why
> the SpiceDisplay is ref'ed.

Looking at virt_viewer_display_spice_new and at _finalize, I think
VirtViewerDisplaySpice already owns a reference to self->priv->display
even without this explicit 'ref':
self->priv->display = spice_display_new_with_monitor(s, ...);
and
g_object_unref(self->priv->display); in _finalize.

So I guess this extra ref was just leaked.

Christophe

> 
> > ---
> >  src/virt-viewer-display-spice.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/virt-viewer-display-spice.c
> b/src/virt-viewer-display-spice.c
> > index 2ce42cf..e568cfb 100644
> > --- a/src/virt-viewer-display-spice.c
> > +++ b/src/virt-viewer-display-spice.c
> > @@ -298,7 +298,7 @@ virt_viewer_display_spice_new(VirtViewerSessionSpice
> *session,
> >                                        G_CONNECT_SWAPPED);
> >      update_display_ready(self);
> >
> > -    gtk_container_add(GTK_CONTAINER(self),
> g_object_ref(self->priv->display));
> > +    gtk_container_add(GTK_CONTAINER(self),
> GTK_WIDGET(self->priv->display));
> >      gtk_widget_show(GTK_WIDGET(self->priv->display));
> >      g_object_set(self->priv->display,
> >                   "grab-keyboard", TRUE,
> > --
> > 1.9.3
> >
> > _______________________________________________
> > virt-tools-list mailing list
> > virt-tools-list at redhat.com
> > https://www.redhat.com/mailman/listinfo/virt-tools-list

> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20140911/0fee7b51/attachment.sig>


More information about the virt-tools-list mailing list