summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Nehring <evan.d.nehring@gmail.com>2020-06-06 13:40:13 -0400
committerMarinus Schraal <mschraal@gnome.org>2020-06-12 12:54:16 +0200
commit0ae8138c06283b2aa61de69f4b7db2d4fa5a2040 (patch)
tree804e89d0062d1c26a554aece8efab11b9229568b
parentf69200cc00be96418fb8687fa7d4fdbf4b692ee9 (diff)
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
-rw-r--r--gnomemusic/window.py5
1 files changed, 5 insertions, 0 deletions
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)