From: Daniel Colascione Date: Sun, 16 Feb 2014 05:46:05 +0000 (-0800) Subject: Make closing dbus buses actually work X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fa8ac13cbabeee7348f97edf25c8411b1a4528d3;p=emacs.git Make closing dbus buses actually work --- fa8ac13cbabeee7348f97edf25c8411b1a4528d3 diff --cc src/ChangeLog index bcaa0fddcee,bcaa0fddcee..0afc5d39b2f --- a/src/ChangeLog +++ b/src/ChangeLog @@@ -1,3 -1,3 +1,11 @@@ ++2014-02-16 Daniel Colascione ++ ++ * dbusbind.c (xd_lisp_dbus_to_dbus): New function. ++ (xd_get_connection_address): Use it. ++ (xd_close_bus): Use xd_lisp_dbus_to_dbus to instead of ++ xd_get_connection_address because the latter signals if the bus ++ we're trying to close is already disconnected. ++ 2014-02-13 Eli Zaretskii * w32proc.c (start_timer_thread): Pass a non-NULL pointer as last diff --cc src/dbusbind.c index 5680eacd9b2,5680eacd9b2..f6df5107db1 --- a/src/dbusbind.c +++ b/src/dbusbind.c @@@ -973,6 -973,6 +973,13 @@@ xd_get_connection_references (DBusConne return *refcount; } ++/* Convert a Lisp dbus object to a pointer */ ++static DBusConnection* ++xd_lisp_dbus_to_dbus (Lisp_Object bus) ++{ ++ return (DBusConnection *) (intptr_t) XFASTINT (bus); ++} ++ /* Return D-Bus connection address. BUS is either a Lisp symbol, :system or :session, or a string denoting the bus address. */ static DBusConnection * @@@ -985,7 -985,7 +992,7 @@@ xd_get_connection_address (Lisp_Object if (NILP (val)) XD_SIGNAL2 (build_string ("No connection to bus"), bus); else -- connection = (DBusConnection *) (intptr_t) XFASTINT (val); ++ connection = xd_lisp_dbus_to_dbus (val); if (!dbus_connection_get_is_connected (connection)) XD_SIGNAL2 (build_string ("No connection to bus"), bus); @@@ -1080,14 -1080,14 +1087,21 @@@ xd_close_bus (Lisp_Object bus { DBusConnection *connection; Lisp_Object val; ++ Lisp_Object busobj; /* Check whether we are connected. */ val = Fassoc (bus, xd_registered_buses); if (NILP (val)) return; ++ busobj = CDR_SAFE(val); ++ if (NILP (val)) { ++ xd_registered_buses = Fdelete (val, xd_registered_buses); ++ return; ++ } ++ /* Retrieve bus address. */ -- connection = xd_get_connection_address (bus); ++ connection = xd_lisp_dbus_to_dbus (busobj); if (xd_get_connection_references (connection) == 1) {