pidgin.vv: 992f060b: Use the dispose method too.

maiku at soc.pidgin.im maiku at soc.pidgin.im
Wed Jan 7 15:20:57 EST 2009


-----------------------------------------------------------------
Revision: 992f060b88b55f06a8579f7bbf3b2c846d11b785
Ancestor: 26ba71d01eb294168e972de93f911bf0f20b9851
Author: maiku at soc.pidgin.im
Date: 2009-01-07T20:10:07
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/992f060b88b55f06a8579f7bbf3b2c846d11b785

Modified files:
        libpurple/media.c pidgin/gtkmedia.c

ChangeLog: 

Use the dispose method too.

-------------- next part --------------
============================================================
--- libpurple/media.c	45a757f4cf82581bbdf35ebbb3e3b604cde197f3
+++ libpurple/media.c	0ba55271e26591e8945e7c130a0d1297f8f329b2
@@ -92,6 +92,7 @@ static void purple_media_init (PurpleMed
 
 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 @@ purple_media_class_init (PurpleMediaClas
 	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(PurpleMediaStre
 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,48 +294,77 @@ purple_media_session_free(PurpleMediaSes
 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);
-	purple_debug_info("media","purple_media_finalize\n");
+	GList *iter = NULL;
 
+	purple_debug_info("media","purple_media_dispose\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);
+	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)) {
-			purple_media_session_free(sessions->data);
+			PurpleMediaSession *session = sessions->data;
+			if (session->session) {
+				g_object_unref(session->session);
+				session->session = NULL;
+			}
 		}
-		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);
+	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");
+
+	for (; priv->streams; priv->streams = g_list_delete_link(priv->streams, priv->streams))
+		purple_media_stream_free(priv->streams->data);
+
+	if (priv->sessions) {
+		GList *sessions = g_hash_table_get_values(priv->sessions);
+		for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
+			purple_media_session_free(sessions->data);
+		}
+		g_hash_table_destroy(priv->sessions);
 	}
 
 	gst_object_unref(priv->conference);
 
-	parent_class->finalize(media);
+	G_OBJECT_CLASS(parent_class)->finalize(media);
 }
 
 static void
============================================================
--- pidgin/gtkmedia.c	67c08a6910c349ee060c7d905308c6bf440154a5
+++ pidgin/gtkmedia.c	b1dfdba124a88372233dc6e2c7d92251f43923b8
@@ -75,6 +75,7 @@ static void pidgin_media_init (PidginMed
 
 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 @@ pidgin_media_class_init (PidginMediaClas
 /*	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
 }
 
 static void
-pidgin_media_finalize (GObject *media)
+pidgin_media_dispose(GObject *media)
 {
 	PidginMedia *gtkmedia = PIDGIN_MEDIA(media);
-	purple_debug_info("gtkmedia", "pidgin_media_finalize\n");
+	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)
+
+	if (gtkmedia->priv->send_level) {
 		gst_object_unref(gtkmedia->priv->send_level);
-	if (gtkmedia->priv->recv_level)
+		gtkmedia->priv->send_level = NULL;
+	}
+
+	if (gtkmedia->priv->recv_level) {
 		gst_object_unref(gtkmedia->priv->recv_level);
-	if (gtkmedia->priv->display)
+		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->display) {
 		gtk_widget_destroy(gtkmedia->priv->display);
+		gtkmedia->priv->display = NULL;
+	}
+
+	G_OBJECT_CLASS(parent_class)->finalize(media);
 }
 
 static void


More information about the Commits mailing list