[PATCHv2 17/22] channel: deprecate spice_channel_destroy()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This function is somewhat useless, and dangerous since it is calling
g_object_unref() behind your back (although this is mentioned in the
doc, I consider this a bad practice).
---
 gtk/spice-channel.c | 6 +++++-
 gtk/spice-channel.h | 3 ++-
 gtk/spice-session.c | 8 ++++----
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 7c18d87..ea0ed34 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2038,8 +2038,12 @@ SpiceChannel *spice_channel_new(SpiceSession *s, int type, int id)
  * spice_channel_destroy:
  * @channel:
  *
- * Disconnect and unref the @channel. Called by @spice_session_channel_destroy()
+ * Disconnect and unref the @channel.
  *
+ * Deprecated: 0.27: this function has been deprecated because it is
+ * misleading, the object is not actually destroyed. Instead, it is
+ * recommended to call explicitely spice_channel_disconnect() and
+ * g_object_unref().
  **/
 void spice_channel_destroy(SpiceChannel *channel)
 {
diff --git a/gtk/spice-channel.h b/gtk/spice-channel.h
index 1c303b4..8d07383 100644
--- a/gtk/spice-channel.h
+++ b/gtk/spice-channel.h
@@ -107,7 +107,6 @@ GType spice_channel_get_type(void);
 typedef void (*spice_msg_handler)(SpiceChannel *channel, SpiceMsgIn *in);
 
 SpiceChannel *spice_channel_new(SpiceSession *s, int type, int id);
-void spice_channel_destroy(SpiceChannel *channel);
 gboolean spice_channel_connect(SpiceChannel *channel);
 gboolean spice_channel_open_fd(SpiceChannel *channel, int fd);
 void spice_channel_disconnect(SpiceChannel *channel, SpiceChannelEvent reason);
@@ -118,6 +117,8 @@ gboolean spice_channel_flush_finish(SpiceChannel *channel, GAsyncResult *result,
 #ifndef SPICE_DISABLE_DEPRECATED
 SPICE_DEPRECATED
 void spice_channel_set_capability(SpiceChannel *channel, guint32 cap);
+SPICE_DEPRECATED
+void spice_channel_destroy(SpiceChannel *channel);
 #endif
 
 const gchar* spice_channel_type_to_string(gint type);
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 6c5e03a..a7f128a 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1756,9 +1756,8 @@ void spice_session_disconnect(SpiceSession *session)
     memset(s->uuid, 0, sizeof(s->uuid));
 
     spice_session_abort_migration(session);
-    /* we leave disconnecting = TRUE, so that spice_channel_destroy()
-       is not called multiple times on channels that are in pending
-       destroy state. */
+    /* we leave disconnecting = TRUE, so that spice_channel_disconnect()
+       is not called multiple times */
 }
 
 /**
@@ -2066,7 +2065,8 @@ static void spice_session_channel_destroy(SpiceSession *session, SpiceChannel *c
     g_signal_emit(session, signals[SPICE_SESSION_CHANNEL_DESTROY], 0, channel);
 
     g_clear_object(&channel->priv->session);
-    spice_channel_destroy(channel);
+    spice_channel_disconnect(channel, SPICE_CHANNEL_NONE);
+    g_object_unref(channel);
 }
 
 G_GNUC_INTERNAL
-- 
2.1.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]