[gnome-music/wip/jfelder/3-32-playlist-creation-populate] playlistview: Do not add a playlist if the view is not populated



commit 7e0479f56a087d058c07053c1866b93195e47b2a
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Apr 24 08:35:36 2019 +0200

    playlistview: Do not add a playlist if the view is not populated
    
    Since commit 0faaeea7, the views are populated when opened. This means
    that a playlist can be created before the PlaylistView has been
    populated. In that case, the newly created playlist will be displayed
    two times: one because of the playlist creation logic and a second
    time because of the populate logic.
    
    Fix the issue by doing nothing in PlaylistView on playlist creation if
    the sidebar is not populated. The playlist will be correctly displayed
    on populate.
    
    (cherry picked from commit 17fff104055f06e71be97d24021b4ba1fd24614b)

 gnomemusic/views/playlistview.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/views/playlistview.py b/gnomemusic/views/playlistview.py
index e3992cec..42f5d664 100644
--- a/gnomemusic/views/playlistview.py
+++ b/gnomemusic/views/playlistview.py
@@ -749,7 +749,13 @@ class PlaylistView(BaseView):
 
     @log
     def _on_playlist_created(self, playlists, playlist):
-        """Add new playlist to sidebar"""
+        """Adds new playlist to sidebar
+
+        If the sidebar has not been populated yet, it has no effect:
+        the playlist will be displayed once the playlists are loaded.
+        """
+        if not self._init:
+            return
         self._add_playlist_to_sidebar(playlist)
 
     @log


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