[gnome-music/wip/mschraal/remove-playlists-loaded-signal: 2/3] mpris: Fix early signal crash



commit db3332c2c81c572faa4e06d4599d545b503909cd
Author: Marinus Schraal <mschraal gnome org>
Date:   Thu Jan 9 16:03:34 2020 +0100

    mpris: Fix early signal crash
    
    During setup, when an early signal is sent, the DBusInterface might not
    be ready. Resulting in a crash.
    
    Instead, wait until the signal dict is filled before trying to send a
    signal.

 gnomemusic/mpris.py | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index dc9822a4..03408fa8 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -46,6 +46,7 @@ class DBusInterface:
         :param str path: object path
         """
         self._path = path
+        self._signals = None
         Gio.bus_get(Gio.BusType.SESSION, None, self._bus_get_sync, name)
 
     def _bus_get_sync(self, source, res, name):
@@ -124,6 +125,9 @@ class DBusInterface:
             invocation.return_value(None)
 
     def _dbus_emit_signal(self, signal_name, values):
+        if self._signals is None:
+            return
+
         signal = self._signals[signal_name]
         parameters = []
         for arg_name, arg_signature in signal['args'].items():


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]