diff options
-rw-r--r-- | src/gabble-connection.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/gabble-connection.c b/src/gabble-connection.c index 198751976..45becf6d1 100644 --- a/src/gabble-connection.c +++ b/src/gabble-connection.c @@ -1515,9 +1515,12 @@ close_all_channels (GabbleConnection *conn) if (priv->media_channels) { - for (i = 0; i < priv->media_channels->len; i++) + GPtrArray *tmp = priv->media_channels; + priv->media_channels = NULL; + + for (i = 0; i < tmp->len; i++) { - GabbleMediaChannel *chan = g_ptr_array_index (priv->media_channels, i); + GabbleMediaChannel *chan = g_ptr_array_index (tmp, i); g_debug ("%s: about to unref channel with ref_count %d", G_STRFUNC, G_OBJECT (chan)->ref_count); @@ -1525,8 +1528,7 @@ close_all_channels (GabbleConnection *conn) g_object_unref (chan); } - g_ptr_array_free (priv->media_channels, TRUE); - priv->media_channels = NULL; + g_ptr_array_free (tmp, TRUE); } if (priv->jingle_sessions) @@ -2564,11 +2566,14 @@ media_channel_closed_cb (GabbleMediaChannel *chan, gpointer user_data) GabbleConnection *conn = GABBLE_CONNECTION (user_data); GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (conn); - g_debug ("%s: removing media channel %p with ref count %d", G_STRFUNC, chan, G_OBJECT (chan)->ref_count); - - g_ptr_array_remove (priv->media_channels, chan); + if (priv->media_channels) + { + g_debug ("%s: removing media channel %p with ref count %d", + G_STRFUNC, chan, G_OBJECT (chan)->ref_count); - g_object_unref (chan); + g_ptr_array_remove (priv->media_channels, chan); + g_object_unref (chan); + } } /** |