[gnome-music/wip/mschraal/window-stackswitcher-duplication-3.36] window: Prevent creating new views if already loaded



commit 0ae8138c06283b2aa61de69f4b7db2d4fa5a2040
Author: Evan Nehring <evan d nehring gmail com>
Date:   Sat Jun 6 13:40:13 2020 -0400

    window: Prevent creating new views if already loaded
    
    Currently, if the user moves/deletes all songs in the music folder, and
    then moves/adds them back, Music will load duplicates of all views
    (albums, artists, songs, etc.).
    
    To fix this, first check one of the views to make sure it is not
    initialized already. Only one view is checked because all views are
    loaded together.
    
    Closes: #387

 gnomemusic/window.py | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 8c5a88a8..3b56bfb1 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -256,6 +256,11 @@ class Window(Gtk.ApplicationWindow):
         self._headerbar.props.state = HeaderBar.State.MAIN
         self._headerbar.props.stack = self._stack
 
+        # All views are created together, so if the album view is
+        # already initialized, assume the rest are as well.
+        if self.views[View.ALBUM] is not None:
+            return
+
         self.views[View.ALBUM] = AlbumsView(self._app)
         self.views[View.ARTIST] = ArtistsView(self._app)
         self.views[View.SONG] = SongsView(self._app)


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