[gnome-music/wip/jfelder/coredisc-duration-change: 1/2] corealbum: Ensure that the album duration is correctly computed




commit 15fc71bebe4d190f4405cd36faca06ff060fa974
Author: Jean Felder <jfelder src gnome org>
Date:   Mon Aug 17 11:56:49 2020 +0200

    corealbum: Ensure that the album duration is correctly computed
    
    When a CoreAlbum model is created, the CoreDiscs it contains can
    sometimes be quickly created (before the "items-changed" signal is
    connected). In that case, the album duration is not correctly computed
    because the duration of the CoreDiscs which already exist is never
    taken into account.
    
    Fix the issue by manually calling the "items-changed" callback of the
    CoreAlbum model before connecting the signal. This way, the duration
    of all the CoreDiscs is used to compute the CoreAlbum duration.

 gnomemusic/corealbum.py | 1 +
 1 file changed, 1 insertion(+)
---
diff --git a/gnomemusic/corealbum.py b/gnomemusic/corealbum.py
index d279e811..c3660374 100644
--- a/gnomemusic/corealbum.py
+++ b/gnomemusic/corealbum.py
@@ -91,6 +91,7 @@ class CoreAlbum(GObject.GObject):
     def model(self):
         if self._model is None:
             self._model = self._get_album_model()
+            self._model.items_changed(0, 0, self._model.get_n_items())
             self._model.connect("items-changed", self._on_list_items_changed)
 
         return self._model


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