Mercurial > pidgin
changeset 26005:83704757fa36
Use the dispose method too.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Wed, 07 Jan 2009 20:10:07 +0000 |
parents | 2d76bee4a98c |
children | d703474d6b81 |
files | libpurple/media.c pidgin/gtkmedia.c |
diffstat | 2 files changed, 100 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/media.c Wed Jan 07 08:28:17 2009 +0000 +++ b/libpurple/media.c Wed Jan 07 20:10:07 2009 +0000 @@ -92,6 +92,7 @@ static void purple_media_class_init (PurpleMediaClass *klass); static void purple_media_init (PurpleMedia *media); +static void purple_media_dispose (GObject *object); static void purple_media_finalize (GObject *object); static void purple_media_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static void purple_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); @@ -179,6 +180,7 @@ GObjectClass *gobject_class = (GObjectClass*)klass; parent_class = g_type_class_peek_parent(klass); + gobject_class->dispose = purple_media_dispose; gobject_class->finalize = purple_media_finalize; gobject_class->set_property = purple_media_set_property; gobject_class->get_property = purple_media_get_property; @@ -274,7 +276,6 @@ purple_media_stream_free(PurpleMediaStream *stream) { g_free(stream->participant); - g_object_unref(stream->stream); if (stream->local_candidates) fs_candidate_list_destroy(stream->local_candidates); @@ -293,19 +294,63 @@ purple_media_session_free(PurpleMediaSession *session) { g_free(session->id); - g_object_unref(session->session); g_free(session); } static void -purple_media_finalize (GObject *media) +purple_media_dispose(GObject *media) +{ + PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media); + GList *iter = NULL; + + purple_debug_info("media","purple_media_dispose\n"); + + purple_media_manager_remove_media(purple_media_manager_get(), + PURPLE_MEDIA(media)); + + if (priv->pipeline) { + GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(priv->pipeline)); + gst_bus_remove_signal_watch(bus); + gst_object_unref(bus); + gst_element_set_state(priv->pipeline, GST_STATE_NULL); + gst_object_unref(priv->pipeline); + priv->pipeline = NULL; + } + + for (iter = priv->streams; iter; iter = g_list_next(iter)) { + PurpleMediaStream *stream = iter->data; + if (stream->stream) { + g_object_unref(stream->stream); + stream->stream = NULL; + } + } + + if (priv->sessions) { + GList *sessions = g_hash_table_get_values(priv->sessions); + for (; sessions; sessions = g_list_delete_link(sessions, sessions)) { + PurpleMediaSession *session = sessions->data; + if (session->session) { + g_object_unref(session->session); + session->session = NULL; + } + } + } + + if (priv->participants) { + GList *participants = g_hash_table_get_values(priv->participants); + for (; participants; participants = g_list_delete_link(participants, participants)) + g_object_unref(participants->data); + } + + G_OBJECT_CLASS(parent_class)->finalize(media); +} + +static void +purple_media_finalize(GObject *media) { PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media); purple_debug_info("media","purple_media_finalize\n"); - purple_media_manager_remove_media(purple_media_manager_get(), - PURPLE_MEDIA(media)); - for (; priv->streams; priv->streams = g_list_delete_link(priv->streams, priv->streams)) purple_media_stream_free(priv->streams->data); @@ -317,24 +362,9 @@ g_hash_table_destroy(priv->sessions); } - if (priv->participants) { - GList *participants = g_hash_table_get_values(priv->participants); - for (; participants; participants = g_list_delete_link(participants, participants)) - g_object_unref(participants->data); - g_hash_table_destroy(priv->participants); - } - - if (priv->pipeline) { - GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(priv->pipeline)); - gst_bus_remove_signal_watch(bus); - gst_object_unref(bus); - gst_element_set_state(priv->pipeline, GST_STATE_NULL); - gst_object_unref(priv->pipeline); - } - gst_object_unref(priv->conference); - parent_class->finalize(media); + G_OBJECT_CLASS(parent_class)->finalize(media); } static void
--- a/pidgin/gtkmedia.c Wed Jan 07 08:28:17 2009 +0000 +++ b/pidgin/gtkmedia.c Wed Jan 07 20:10:07 2009 +0000 @@ -75,6 +75,7 @@ static void pidgin_media_class_init (PidginMediaClass *klass); static void pidgin_media_init (PidginMedia *media); +static void pidgin_media_dispose (GObject *object); static void pidgin_media_finalize (GObject *object); static void pidgin_media_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static void pidgin_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); @@ -130,6 +131,7 @@ /* GtkContainerClass *container_class = (GtkContainerClass*)klass; */ parent_class = g_type_class_peek_parent(klass); + gobject_class->dispose = pidgin_media_dispose; gobject_class->finalize = pidgin_media_finalize; gobject_class->set_property = pidgin_media_set_property; gobject_class->get_property = pidgin_media_get_property; @@ -259,20 +261,56 @@ } static void -pidgin_media_finalize (GObject *media) +pidgin_media_dispose(GObject *media) +{ + PidginMedia *gtkmedia = PIDGIN_MEDIA(media); + purple_debug_info("gtkmedia", "pidgin_media_dispose\n"); + + if (gtkmedia->priv->media) { + GstElement *videosendbin = NULL, *videorecvbin = NULL; + + purple_media_get_elements(gtkmedia->priv->media, NULL, NULL, + &videosendbin, &videorecvbin); + + if (videorecvbin) { + gst_element_set_locked_state(videorecvbin, TRUE); + gst_element_set_state(videorecvbin, GST_STATE_NULL); + } + if (videosendbin) { + gst_element_set_locked_state(videosendbin, TRUE); + gst_element_set_state(videosendbin, GST_STATE_NULL); + } + + pidgin_media_disconnect_levels(gtkmedia->priv->media, gtkmedia); + g_object_unref(gtkmedia->priv->media); + gtkmedia->priv->media = NULL; + } + + if (gtkmedia->priv->send_level) { + gst_object_unref(gtkmedia->priv->send_level); + gtkmedia->priv->send_level = NULL; + } + + if (gtkmedia->priv->recv_level) { + gst_object_unref(gtkmedia->priv->recv_level); + gtkmedia->priv->recv_level = NULL; + } + + G_OBJECT_CLASS(parent_class)->dispose(media); +} + +static void +pidgin_media_finalize(GObject *media) { PidginMedia *gtkmedia = PIDGIN_MEDIA(media); purple_debug_info("gtkmedia", "pidgin_media_finalize\n"); - if (gtkmedia->priv->media) { - pidgin_media_disconnect_levels(gtkmedia->priv->media, gtkmedia); - g_object_unref(gtkmedia->priv->media); + + if (gtkmedia->priv->display) { + gtk_widget_destroy(gtkmedia->priv->display); + gtkmedia->priv->display = NULL; } - if (gtkmedia->priv->send_level) - gst_object_unref(gtkmedia->priv->send_level); - if (gtkmedia->priv->recv_level) - gst_object_unref(gtkmedia->priv->recv_level); - if (gtkmedia->priv->display) - gtk_widget_destroy(gtkmedia->priv->display); + + G_OBJECT_CLASS(parent_class)->finalize(media); } static void