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



commit 8e4078fcd28df6b6c3383801e8174bb70c6ded13
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 | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/gnomemusic/widgets/coverstack.py b/gnomemusic/widgets/coverstack.py
index 72d0a3af..4b54ec5b 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,11 @@ 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._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]