[gnome-music/wip/mschraal/player-no-play-empty-playlist] player: Do not set playing on emtpy playlist



commit be2f882cf817d88429d85e34d4ff4a1dfa778b83
Author: Marinus Schraal <mschraal gnome org>
Date:   Fri Jan 3 10:51:35 2020 +0100

    player: Do not set playing on emtpy playlist
    
    If the playlist model is empty, do not allow to set a song. This will
    result in a crash.
    
    Fixes: #348, #355

 gnomemusic/player.py | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 0e23754a..f9b13cb3 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -235,6 +235,9 @@ class PlayerPlaylist(GObject.GObject):
         :returns: The selected song
         :rtype: CoreSong
         """
+        if self._model.get_n_items() == 0:
+            return None
+
         if song is None:
             if self.props.repeat_mode == RepeatMode.SHUFFLE:
                 position = randrange(0, self._model.get_n_items())


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