changeset 104355:7d92d0b5edc6

* net/dbus.el (top): Apply `dbus-init-bus' for the :session bus only if it is running already.
author Michael Albinus <michael.albinus@gmx.de>
date Wed, 19 Aug 2009 07:08:57 +0000
parents 7d0f4f179b3d
children 9501bdf3d7dc
files lisp/net/dbus.el
diffstat 1 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/net/dbus.el	Wed Aug 19 03:03:05 2009 +0000
+++ b/lisp/net/dbus.el	Wed Aug 19 07:08:57 2009 +0000
@@ -41,15 +41,6 @@
 (defvar dbus-debug)
 (defvar dbus-registered-functions-table)
 
-;; Initialize :system and :session buses.  This adds their file
-;; descriptors to input_wait_mask, in order to detect incoming
-;; messages immediately.
-;; We must avoid to call the function twice for a bus, because the
-;; DBusWatch will be removed then.
-(when (and (featurep 'dbusbind) (not (featurep 'dbus)))
-  (dbus-init-bus :system)
-  (dbus-init-bus :session))
-
 ;; Pacify byte compiler.
 (eval-when-compile
   (require 'cl))
@@ -841,6 +832,14 @@
 	 (cons property (dbus-get-property bus service path interface property))
 	 'append)))))
 
+;; Initialize :system and :session buses.  This adds their file
+;; descriptors to input_wait_mask, in order to detect incoming
+;; messages immediately.
+(dbus-ignore-errors
+  (dbus-init-bus :system)
+  (when (getenv "DBUS_SESSION_BUS_ADDRESS")
+    (dbus-init-bus :session)))
+
 (provide 'dbus)
 
 ;; arch-tag: a47caf84-9162-4811-90cc-5d388e37b9bd