[Spice-devel] [PATCHv2 19/22] session: keep a reference on disconnect

Marc-André Lureau marcandre.lureau at redhat.com
Wed Nov 26 09:56:10 PST 2014


It is idiomatic for client code to clean up its reference on channel
disconnection. Keeping a reference during disconnect helps solving
potential crashes if the session is unref'ed 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 8059f2f..f87e7ea 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1740,6 +1740,7 @@ void spice_session_disconnect(SpiceSession *session)
     if (s->disconnecting)
         return;
 
+    g_object_ref(session);
     s->disconnecting = TRUE;
     s->cmain = NULL;
 
@@ -1757,6 +1758,7 @@ void spice_session_disconnect(SpiceSession *session)
 
     spice_session_abort_migration(session);
     s->disconnecting = FALSE;
+    g_object_unref(session);
 }
 
 /**
-- 
2.1.0



More information about the Spice-devel mailing list