[gnome-music/wip/mschraal/core-thumb-property: 5/9] artstack: Disconnect notification on coreobject change



commit 4acedcf73436476105581f7b47ff850c6d69af17
Author: Marinus Schraal <mschraal gnome org>
Date:   Sun Jun 14 16:50:45 2020 +0200

    artstack: Disconnect notification on coreobject change
    
    When fast switching through a mixed list of songs, the older
    notification handlers may lag behind and overwrite a newer stack change.
    Effectively showing the wrong art for the album.
    
    Always disconnect the handler to stop listening to the previous
    coreobjects thumbnail change.

 gnomemusic/widgets/artstack.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/widgets/artstack.py b/gnomemusic/widgets/artstack.py
index b15a3911..ac0f7c83 100644
--- a/gnomemusic/widgets/artstack.py
+++ b/gnomemusic/widgets/artstack.py
@@ -49,6 +49,7 @@ class ArtStack(Gtk.Stack):
         self._cache = None
         self._handler_id = None
         self._size = None
+        self._thumbnail_id = 0
 
         self._cover_a = Gtk.Image()
         self._cover_b = Gtk.Image()
@@ -88,9 +89,13 @@ class ArtStack(Gtk.Stack):
 
     @coreobject.setter
     def coreobject(self, coreobject):
+        if self._thumbnail_id != 0:
+            self._coreobject.disconnect(self._thumbnail_id)
+            self._thumbnail_id = 0
+
         self._coreobject = coreobject
 
-        self._coreobject.connect(
+        self._thumbnail_id = self._coreobject.connect(
             "notify::thumbnail", self._on_thumbnail_changed)
 
         if self._coreobject.props.thumbnail is not None:


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