/pidgin/main: 8a6f23f61052: media: make "init-media" signal hand...

Jakub Adam jakub.adam at ktknet.cz
Fri Mar 13 19:45:21 EDT 2015


Changeset: 8a6f23f610520cea8ff9cda2383ad6577996c48d
Author:	 Jakub Adam <jakub.adam at ktknet.cz>
Date:	 2014-08-12 14:39 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/8a6f23f61052

Description:

media: make "init-media" signal handler optional

Change the logic so that the PurpleMedia instance isn't disposed when
"init-media" has no connected handlers.

We want the media object freed only when some signal callback function
explicitly returns FALSE, indicating an error during the initialization.

This is mostly useful for the imminent addition of private media streams.

diffstat:

 libpurple/mediamanager.c |  17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diffs (35 lines):

diff --git a/libpurple/mediamanager.c b/libpurple/mediamanager.c
--- a/libpurple/mediamanager.c
+++ b/libpurple/mediamanager.c
@@ -313,7 +313,7 @@ purple_media_manager_create_media(Purple
 {
 #ifdef USE_VV
 	PurpleMedia *media;
-	gboolean signal_ret;
+	guint signal_id;
 
 	media = PURPLE_MEDIA(g_object_new(purple_media_get_type(),
 			     "manager", manager,
@@ -322,12 +322,17 @@ purple_media_manager_create_media(Purple
 			     "initiator", initiator,
 			     NULL));
 
-	g_signal_emit(manager, purple_media_manager_signals[INIT_MEDIA], 0,
-			media, account, remote_user, &signal_ret);
+	signal_id = purple_media_manager_signals[INIT_MEDIA];
 
-	if (signal_ret == FALSE) {
-		g_object_unref(media);
-		return NULL;
+	if (g_signal_has_handler_pending(manager, signal_id, 0, FALSE)) {
+		gboolean signal_ret;
+
+		g_signal_emit(manager, signal_id, 0, media, account, remote_user,
+				&signal_ret);
+		if (signal_ret == FALSE) {
+			g_object_unref(media);
+			return NULL;
+		}
 	}
 
 	manager->priv->medias = g_list_append(manager->priv->medias, media);



More information about the Commits mailing list