/srv/mercurial-server/detachablepurple: b940392f535c: Rewritten ...

Gilles Bedel gillux at cpw.pidgin.im
Fri Jun 15 22:01:50 EDT 2012


Changeset: b940392f535c8af3c748250439478ebc154ca4f0
Author:	 Gilles Bedel <gillux at cpw.pidgin.im>
Date:	 2012-05-25 19:28 +0000
Branch:	 cpw.gillux.detachablepurple
URL: http://hg.pidgin.im/srv/mercurial-server/detachablepurple/rev/b940392f535c

Description:

Rewritten the RequestClosed signal loop prevention system.
Before we used the mirror mode trick but as we want to get
rid of this hack, here is another solution.

diffstat:

 libpurple/account.c       |   2 --
 libpurple/dbus/account.c  |  20 +-------------------
 libpurple/dbus/callback.c |  12 +++++++++---
 3 files changed, 10 insertions(+), 24 deletions(-)

diffs (79 lines):

diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -1091,8 +1091,6 @@
 		request_id = purple_callback_get_req_id(info->ui_handle);
 		if (request_id)
 			purple_callback_run_request_RPC(request_id, 0);
-		else
-			purple_debug_error("dbus", "Couldn't inform the daemon about the closing of an account request from which the request id is unknown\n");
 	}
 
 	purple_account_request_info_unref(info);
diff --git a/libpurple/dbus/account.c b/libpurple/dbus/account.c
--- a/libpurple/dbus/account.c
+++ b/libpurple/dbus/account.c
@@ -62,24 +62,6 @@
 }
 
 /**
- * A wrapper for purple_account_request_close() used in request_authorize_cb().
- * We need to run this function not in remote mode, otherwise it also runs
- * the dbus method RunRequest(request_id, 0) to inform the daemon we closed
- * this request. It's a non-sense since this we are calling
- * purple_account_request_close() because we received a RequestClosed dbus
- * signal, which means the request is already handled.
- */
-static void
-purple_account_local_request_close(void *ui_handle)
-{
-	PurpleRunningMode mode;
-	mode = purple_core_get_running_mode();
-	purple_core_set_running_mode(PURPLE_RUN_MIRROR_MODE);
-	purple_account_request_close(ui_handle);
-	purple_core_set_running_mode(mode);
-}
-
-/**
  * Callback, called when we receive a dbus "RequestAuthorize" signal.
  */
 static void
@@ -107,7 +89,7 @@
 	         * (with the RequestClosed dbus signal), then it will be
 	         * automatically and properly closed */
 	        close_req = g_cclosure_new(
-	                        G_CALLBACK(purple_account_local_request_close),
+	                        G_CALLBACK(purple_account_request_close),
 	                        h, NULL);
 	        g_closure_set_marshal(close_req, purple_nullmarshaller);
 	        purple_callback_register_req_id(request_id, close_req, h);
diff --git a/libpurple/dbus/callback.c b/libpurple/dbus/callback.c
--- a/libpurple/dbus/callback.c
+++ b/libpurple/dbus/callback.c
@@ -391,6 +391,7 @@
 	PurpleDBusCallback* handler = purple_dbus_callback_get_instance();
 	PurpleDBusClientPendingRequest *req;
 	void *key = GINT_TO_POINTER(request_id);
+	GClosure *close;
 
 	g_return_if_fail(handler != NULL);
 	g_return_if_fail(handler->client_reqs != NULL);
@@ -400,10 +401,15 @@
 	if (!req)
 		return;
 
-	g_closure_invoke(req->close, NULL, 0, NULL, NULL);
-
-	/* Forget about this closed pending request */
+	/* We want to run the local closing request function while not
+	 * triggering a "RunRequest" D-Bus signal. So we first drop the request
+	 * so that it will not be able to run it again. Yet, we still need the
+	 * closing callback so we ref it before dropping the request. */
+	close = req->close;
+	g_closure_ref(close);
 	g_hash_table_remove(handler->client_reqs, key);
+	g_closure_invoke(close, NULL, 0, NULL, NULL);
+	g_closure_unref(close);
 }
 
 /**



More information about the Commits mailing list