[gnome-shell/wip/rstrode/rhel-7.9: 82/86] workspacesDisplay: Disconnect MetaLater and parent signals on destroy




commit c2d54e1a90834132981a61595bec3ea54e74c848
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Mon Aug 12 16:25:48 2019 +0200

    workspacesDisplay: Disconnect MetaLater and parent signals on destroy
    
    When the WorkspacesDisplay actor is destroyed we should remove the
    ongoing later and parent widget connections to avoid accessing an
    invalid object on callback.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/700

 js/ui/workspacesView.js | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index dd7bb0e2a7..5dea68f5d4 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -497,6 +497,22 @@ var WorkspacesDisplay = new Lang.Class({
         this._keyPressEventId = 0;
 
         this._fullGeometry = null;
+
+        this.actor.connect('destroy', this._onDestroy.bind(this));
+    },
+
+    _onDestroy() {
+        if (this._notifyOpacityId) {
+            let parent = this.actor.get_parent();
+            if (parent)
+                parent.disconnect(this._notifyOpacityId);
+            this._notifyOpacityId = 0;
+        }
+
+        if (this._parentSetLater) {
+            Meta.later_remove(this._parentSetLater);
+            this._parentSetLater = 0;
+        }
     },
 
     _onPan(action) {
@@ -639,7 +655,11 @@ var WorkspacesDisplay = new Lang.Class({
             oldParent.disconnect(this._notifyOpacityId);
         this._notifyOpacityId = 0;
 
-        Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
+        if (this._parentSetLater)
+            return;
+
+        this._parentSetLater = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
+            this._parentSetLater = 0;
             let newParent = this.actor.get_parent();
             if (!newParent)
                 return;


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