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



commit 27c9c30bba7f19a6fe01824c02fc2ba99c4a03db
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 867dcc8c..73c47e7d 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -640,7 +640,15 @@ class MediaPlayer2Service(Server):
                              GLib.Variant.new_tuple(GLib.Variant('(oss)', playlist)))
 
     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]