[virt-tools-list] [PATCH 05/11] virt-viewer-window: Use a borrowed reference to app

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


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

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

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 708678a..77283f5 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -164,7 +164,7 @@ virt_viewer_window_set_property (GObject *object, guint property_id,
 
     case PROP_APP:
         g_return_if_fail(priv->app == NULL);
-        priv->app = g_value_dup_object(value);
+        priv->app = g_value_get_object(value);
         break;
 
     default:
@@ -183,11 +183,6 @@ virt_viewer_window_dispose (GObject *object)
         priv->display = NULL;
     }
 
-    if (priv->app) {
-        g_object_unref(priv->app);
-        priv->app = NULL;
-    }
-
     g_free(priv->subtitle);
     priv->subtitle = NULL;
 }
-- 
1.7.7.6




More information about the virt-tools-list mailing list