[gnome-music/wip/mschraal/core] player: Fix crash when switching albums



commit 463ffecae82df5ccd946c845bb13789a92eef538
Author: Marinus Schraal <mschraal gnome org>
Date:   Sun Jun 23 21:26:54 2019 +0200

    player: Fix crash when switching albums
    
    If playing position is > than the new albums amount of songs.

 gnomemusic/player.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 0ab3e623..6cd59ec9 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -446,7 +446,9 @@ class PlayerPlaylist(GObject.GObject):
         :returns: the song being played or None if there are no songs
         :rtype: Grl.Media
         """
-        if self._model.get_n_items() != 0:
+        n_items = self._model.get_n_items()
+        if (n_items != 0
+                and n_items > self._position):
             current_song = self._model[self._position]
             if current_song.props.state == SongWidget.State.PLAYING:
                 return current_song.props.media


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