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



commit 24be914656ed6763d861fe37a531155d1776019e
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 af60ce57..ac5726c1 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -709,7 +709,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]