[virt-tools-list] [PATCH 06/11] virt-viewer-display: Use a borrowed reference to session

Hans de Goede hdegoede at redhat.com
Sun Mar 4 19:05:57 UTC 2012


Before this patch there was a cyclic reference between VirtViewerSesion and
VirtViewerDisplay, since all VirtViewerDisplays are created / destroyed by
VirtViewerSession it is safe to assume that lifetime of VirtViewerSession >=
VirtViewerDisplay, so VirtViewerDisplay can take a borrowed reference
breaking the circle, and allowing proper cleanup on exit.

Note that there is no g_object_unref removed from virt-viewer-display, this
because there is no finalize / dispose and before this patch
VirtViewerDisplay never unref-ed the reference it hold to the session.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 src/virt-viewer-display.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index ec4fe52..40d23ad 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -268,7 +268,7 @@ virt_viewer_display_set_property(GObject *object,
         break;
     case PROP_SESSION:
         g_warn_if_fail(priv->session == NULL);
-        priv->session = g_value_dup_object(value);
+        priv->session = g_value_get_object(value);
         break;
 
     default:
-- 
1.7.7.6




More information about the virt-tools-list mailing list