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



commit f40e67bdc8665919becdf73589eef38283de4a2a
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 0e16c7f5..c426df9e 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_a.props.visible = True
@@ -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]