<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 13, 2014 at 6:20 PM, Marc-André Lureau <span dir="ltr"><<a href="mailto:marcandre.lureau@gmail.com" target="_blank">marcandre.lureau@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">SpiceSession in spice-gtk v0.27 removes channels from session during<br>
disconnect (and not when they are actually disposed). When no channels<br>
are left, session-disconnected is emitted, and the VirtViewerSession<br>
will be unref from the application. Use a weak reference to self to<br>
avoid crashing after calling spice_session_disconnect()<br>
<br>
As a workaround for existing clients, spice-gtk v0.27 will defer the<br>
disconnection to idle time.  But the fix still makes sense and would<br>
prevent potentially future issues if spice-gtk changes back to sync<br>
disconnection.<br>
<br>
(the alternative of calling ref/unref would keep recreating session,<br>
 which is something it can avoid when leaving the application)<br>
---<br>
 src/virt-viewer-session-spice.c | 5 +++++<br>
 1 file changed, 5 insertions(+)<br>
<br>
diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c<br>
index 2eb2224..afeeadd 100644<br>
--- a/src/virt-viewer-session-spice.c<br>
+++ b/src/virt-viewer-session-spice.c<br>
@@ -292,10 +292,15 @@ virt_viewer_session_spice_close(VirtViewerSession *session)<br>
<br>
     g_return_if_fail(self != NULL);<br>
<br>
+    g_object_add_weak_pointer(G_OBJECT(self), (gpointer*)&self);<br>
+<br>
     virt_viewer_session_clear_displays(session);<br>
<br>
     if (self->priv->session) {<br>
         spice_session_disconnect(self->priv->session);<br>
+        if (!self)<br>
+            return;<br>
+ </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
         g_object_unref(self->priv->session);<br>
         self->priv->session = NULL;<br>
         self->priv->gtk_session = NULL;<br></blockquote><div><br></div><div>It's missing g_object_remove_weak_pointer() which I just added.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888">--<br>
1.9.3<br>
<br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Marc-André Lureau</div>
</div></div>