From 0a7b438d76c9e1e52dfdfd8ced37d566ed8e4067 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 29 Jul 2011 23:04:43 +0200 Subject: [PATCH] Handle errors when connecting to D-Bus and libindicate by stopping the MPRIS frontend --- mopidy/frontends/mpris/__init__.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mopidy/frontends/mpris/__init__.py b/mopidy/frontends/mpris/__init__.py index 6656347f..4e52fd79 100644 --- a/mopidy/frontends/mpris/__init__.py +++ b/mopidy/frontends/mpris/__init__.py @@ -57,13 +57,18 @@ class MprisFrontend(ThreadingActor, BackendListener): self.mpris_object = None def on_start(self): - self.mpris_object = objects.MprisObject() - self.send_startup_notification() + try: + self.mpris_object = objects.MprisObject() + self.send_startup_notification() + except Exception as e: + logger.error(u'MPRIS frontend setup failed (%s)', e) + self.stop() def on_stop(self): logger.debug(u'Removing MPRIS object from D-Bus connection...') - self.mpris_object.remove_from_connection() - self.mpris_object = None + if self.mpris_object: + self.mpris_object.remove_from_connection() + self.mpris_object = None logger.debug(u'Removed MPRIS object from D-Bus connection') def send_startup_notification(self):