[gnome-music/wip/jfelder/coverstack-destroy] coverstack: Do not update the cover on destroy



commit 79559d59cc0e1ab2ae26920cf02af1cac3da64f2
Author: Jean Felder <jfelder src gnome org>
Date:   Sat Mar 14 19:50:23 2020 +0100

    coverstack: Do not update the cover on destroy
    
    On rare occasions, the CoverStack can be destroyed while the art is
    updated. This can result in an error once the art is retrieved because
    the CoverStack does not have children anymore.

 gnomemusic/widgets/coverstack.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/gnomemusic/widgets/coverstack.py b/gnomemusic/widgets/coverstack.py
index 72d0a3af..cfc1c667 100644
--- a/gnomemusic/widgets/coverstack.py
+++ b/gnomemusic/widgets/coverstack.py
@@ -67,6 +67,8 @@ class CoverStack(Gtk.Stack):
         self.props.transition_type = Gtk.StackTransitionType.CROSSFADE
         self.props.visible_child_name = "loading"
 
+        self.connect("destroy", self._on_destroy)
+
         self.show_all()
 
     @GObject.Property(type=object, flags=GObject.ParamFlags.READWRITE)
@@ -134,3 +136,12 @@ class CoverStack(Gtk.Stack):
         self._art = None
 
         self.emit('updated')
+
+    def _on_destroy(self, widget):
+        # If the CoverStack is destroyed while the art is updated,
+        # an error can be coccur once the art is retrieved because
+        # the CoverStack does not have children anymore.
+        if (self._art is not None and
+                self._handler_id is not None):
+            self._art.disconnect(self._handler_id)
+            self._handler_id = None


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