[gnome-music/wip/jfelder/mpris-gsconnect-debug: 14/14] mpris: Handle clients which request the volume property



commit 7e39cf53bc7df2fbd76624e6440b96a7578a8932
Author: Jean Felder <jfelder src gnome org>
Date:   Thu May 30 16:38:22 2019 +0200

    mpris: Handle clients which request the volume property
    
    Volume property handling has been recently removed from Music (commit
    2bd7fb6b) but some MPRIS clients (for example GSConnect) try to get
    this property and this results in a crash at startup. The client
    should detect that the server (GNOME Music) does not handle the volume
    property and not request it.
    
    Apply a workaround to prevent a crash: return a NULL value.

 gnomemusic/mpris.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index b74c4c53..458a7686 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -678,7 +678,15 @@ class MediaPlayer2Service(Server):
         return mpris_playlists[index + max_count - 1:first_index:-1]
 
     def Get(self, interface_name, property_name):
-        return self.GetAll(interface_name)[property_name]
+        # Some clients (for example GSConnect) try to acesss the volume
+        # property. This results in a crash at startup.
+        # Return nothing to prevent it.
+        try:
+            return self.GetAll(interface_name)[property_name]
+        except KeyError:
+            logger.warning(
+                "MPRIS does not handle {} property".format(property_name))
+            return GLib.Variant("s", "nothing")
 
     def GetAll(self, interface_name):
         if interface_name == MediaPlayer2Service.MEDIA_PLAYER2_IFACE:


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