[Spice-devel] [PATCH spice-gtk v2 18/19] session: keep a reference on disconnect

Marc-André Lureau marcandre.lureau at redhat.com
Thu Nov 13 15:32:41 PST 2014


It is idiomatic for client code to clean up it's reference on channel
disconnection. Keeping a reference during disconnect help solving
potential crashes if the session is unref during callbacks.
---
 gtk/spice-session.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index cb23102..e2a3de3 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1646,6 +1646,7 @@ void spice_session_disconnect(SpiceSession *session)
     if (s->disconnecting)
         return;
 
+    g_object_ref(session);
     s->disconnecting = TRUE;
     s->cmain = NULL;
 
@@ -1663,6 +1664,7 @@ void spice_session_disconnect(SpiceSession *session)
 
     spice_session_abort_migration(session);
     s->disconnecting = FALSE;
+    g_object_unref(session);
 }
 
 /**
-- 
1.9.3



More information about the Spice-devel mailing list