[gnome-music/wip/jfelder/3-32-fix-random-next] player: Ignore {next, previous} if the player is not playing



commit 5b773e93f5e7b903adcca962254f63a68c4c56bb
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Jul 31 11:45:54 2019 +0200

    player: Ignore {next, previous} if the player is not playing
    
    Next and previous song actions can be performed from a shortcut even if
    the player has not started yet. This can result in a crash if the
    player is in shuffle mode because it tries to access the
    shuffle_indexes list which has not been populated yet.
    
    Fix the issue by checking that the player is playing before performing
    these actions.
    
    Closes: #306

 gnomemusic/player.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 52ad2458..67289fb7 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -685,7 +685,8 @@ class Player(GObject.GObject):
 
         Play the next song of the playlist, if any.
         """
-        if self._playlist.next():
+        if (self.props.playing
+                and self._playlist.next()):
             self.play()
 
     @log
@@ -694,6 +695,9 @@ class Player(GObject.GObject):
 
         Play the previous song of the playlist, if any.
         """
+        if not self.props.playing:
+            return
+
         position = self._gst_player.props.position
         if position >= 5:
             self.set_position(0.0)


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