[gnome-music/wip/mschraal/albumwidget-bind-widget-early] albumwidget: Bind ListModel early



commit 6cff6708020f52c341050040bfe5a6d0fbf0babc
Author: Marinus Schraal <mschraal gnome org>
Date:   Sun Feb 16 21:01:45 2020 +0100

    albumwidget: Bind ListModel early
    
    If we start listening to ListModel items-changed signals before binding
    the model to the ListBox, it might not yet be synced and crash in the
    signal callback. The callback assumes the ListBox widgets are already
    created and this might result in a crash.
    
    Bind the ListBox widget before connecting the signal handler.
    
    Closes: #367

 gnomemusic/widgets/artistalbumwidget.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/widgets/artistalbumwidget.py b/gnomemusic/widgets/artistalbumwidget.py
index 2c7e5d73..c8c136e8 100644
--- a/gnomemusic/widgets/artistalbumwidget.py
+++ b/gnomemusic/widgets/artistalbumwidget.py
@@ -80,10 +80,10 @@ class ArtistAlbumWidget(Gtk.Box):
         if self._cover_size_group:
             self._cover_size_group.add_widget(self._cover_stack)
 
-        corealbum.props.model.connect_after(
-            "items-changed", self._on_model_items_changed)
         self._disc_list_box.bind_model(
             corealbum.props.model, self._create_widget)
+        corealbum.props.model.connect_after(
+            "items-changed", self._on_model_items_changed)
 
         corealbum.props.model.items_changed(0, 0, 0)
 


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