[gnome-books/wip/hadess/fix-preview-warnings: 4/4] preview: ensure signals/sources are removed upon destroy



commit 9faa5cda26bd28ca815d42ed262ce06fe0aa26b9
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sat Aug 3 18:33:35 2019 +0200

    preview: ensure signals/sources are removed upon destroy
    
    Some of the objects (e.g. the overlay) will outlive the preview, so
    we need to disconnect signals from them when the preview or one of
    its subcomponents are destroyed.
    
    Also, we were not properly cleaning up some sources upon destruction
    of the nav bar controls.

 src/preview.js | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/src/preview.js b/src/preview.js
index 8daec8aa..4dbcf57a 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -613,7 +613,7 @@ var PreviewNavControls = new Lang.Class({
         this._prevRevealer.show_all();
         this._nextRevealer.show_all();
 
-        this._overlay.connect('motion-notify-event', Lang.bind(this, this._onMotion));
+        this._overlayMotionId = this._overlay.connect('motion-notify-event', Lang.bind(this, 
this._onMotion));
 
         this._tapGesture = new Gtk.GestureMultiPress({ propagation_phase: Gtk.PropagationPhase.CAPTURE,
                                                        touch_only: true,
@@ -636,6 +636,14 @@ var PreviewNavControls = new Lang.Class({
         return false;
     },
 
+    _removeMotionTimeout: function() {
+        if (this._motionId == 0)
+            return;
+
+        Mainloop.source_remove(this._motionId);
+        this._motionId = 0;
+    },
+
     _motionTimeout: function() {
         this._motionId = 0;
         this._visibleInternal = true;
@@ -729,6 +737,14 @@ var PreviewNavControls = new Lang.Class({
     },
 
     destroy: function() {
+        this._unqueueAutoHide();
+        this._removeMotionTimeout();
+
+        if (this._overlayMotionId != 0) {
+            this._overlay.disconnect(this._overlayMotionId);
+            this._overlayMotionId = 0;
+        }
+
         if (this._barRevealer)
             this._barRevealer.destroy();
         this._prevRevealer.destroy();


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