[gnome-music/wip/mschraal/player-no-play-empty-playlist-3-34: 1/2] player: Do not set playing on an emtpy playlist
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/player-no-play-empty-playlist-3-34: 1/2] player: Do not set playing on an emtpy playlist
- Date: Sat, 4 Jan 2020 23:14:33 +0000 (UTC)
commit ee519682fdc2f66e8f0d4529979b62eaf7091019
Author: Marinus Schraal <mschraal gnome org>
Date: Fri Jan 3 10:51:35 2020 +0100
player: Do not set playing on an emtpy playlist
If the playlist model is empty, do not allow to set a song. This will
result in a crash.
In Player the 'play' function has to add an extra check if there is a
current song to play before setting state.
Fixes: #354, #355
gnomemusic/player.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 51f73d6a..e35fc65e 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -241,6 +241,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())
@@ -502,7 +505,8 @@ class Player(GObject.GObject):
if coresong is not None:
self._load(coresong)
- self._gst_player.props.state = Playback.PLAYING
+ if self.props.current_song is not None:
+ self._gst_player.props.state = Playback.PLAYING
@log
def pause(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]