Blame SOURCES/fix-invalid-access-warnings.patch

671c89
From 76eebb42ed4c76970a9debfc0cd41537923eccde Mon Sep 17 00:00:00 2001
671c89
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
671c89
Date: Tue, 5 Dec 2017 02:41:50 +0100
671c89
Subject: [PATCH 1/2] tweener: Save handlers on target and remove them on
671c89
 destroy
671c89
671c89
Saving handlers we had using the wrapper as a property of the object and delete
671c89
them when resetting the object state.
671c89
Without doing this an handler could be called on a destroyed target when this
671c89
happens on the onComplete callback.
671c89
671c89
https://bugzilla.gnome.org/show_bug.cgi?id=791233
671c89
---
671c89
 js/ui/tweener.js | 63 ++++++++++++++++++++++++++++++++++++++----------
671c89
 1 file changed, 50 insertions(+), 13 deletions(-)
671c89
671c89
diff --git a/js/ui/tweener.js b/js/ui/tweener.js
671c89
index bb9ea557c..c04cede25 100644
671c89
--- a/js/ui/tweener.js
671c89
+++ b/js/ui/tweener.js
671c89
@@ -63,30 +63,67 @@ function _getTweenState(target) {
671c89
     return target.__ShellTweenerState;
671c89
 }
671c89
 
671c89
+function _ensureHandlers(target) {
671c89
+    if (!target.__ShellTweenerHandlers)
671c89
+        target.__ShellTweenerHandlers = {};
671c89
+    return target.__ShellTweenerHandlers;
671c89
+}
671c89
+
671c89
 function _resetTweenState(target) {
671c89
     let state = target.__ShellTweenerState;
671c89
 
671c89
     if (state) {
671c89
-        if (state.destroyedId)
671c89
+        if (state.destroyedId) {
671c89
             state.actor.disconnect(state.destroyedId);
671c89
+            delete state.destroyedId;
671c89
+        }
671c89
     }
671c89
 
671c89
+    _removeHandler(target, 'onComplete', _tweenCompleted);
671c89
     target.__ShellTweenerState = {};
671c89
 }
671c89
 
671c89
 function _addHandler(target, params, name, handler) {
671c89
-    if (params[name]) {
671c89
-        let oldHandler = params[name];
671c89
-        let oldScope = params[name + 'Scope'];
671c89
-        let oldParams = params[name + 'Params'];
671c89
-        let eventScope = oldScope ? oldScope : target;
671c89
-
671c89
-        params[name] = () => {
671c89
-            oldHandler.apply(eventScope, oldParams);
671c89
-            handler(target);
671c89
-        };
671c89
-    } else
671c89
-        params[name] = () => { handler(target); };
671c89
+    let wrapperNeeded = false;
671c89
+    let tweenerHandlers = _ensureHandlers(target);
671c89
+
671c89
+    if (!(name in tweenerHandlers)) {
671c89
+        tweenerHandlers[name] = [];
671c89
+        wrapperNeeded = true;
671c89
+    }
671c89
+
671c89
+    let handlers = tweenerHandlers[name];
671c89
+    handlers.push(handler);
671c89
+
671c89
+    if (wrapperNeeded) {
671c89
+        if (params[name]) {
671c89
+            let oldHandler = params[name];
671c89
+            let oldScope = params[name + 'Scope'];
671c89
+            let oldParams = params[name + 'Params'];
671c89
+            let eventScope = oldScope ? oldScope : target;
671c89
+
671c89
+            params[name] = () => {
671c89
+                oldHandler.apply(eventScope, oldParams);
671c89
+                handlers.forEach((h) => h(target));
671c89
+            };
671c89
+        } else {
671c89
+            params[name] = () => { handlers.forEach((h) => h(target)); };
671c89
+        }
671c89
+    }
671c89
+}
671c89
+
671c89
+function _removeHandler(target, name, handler) {
671c89
+    let tweenerHandlers = _ensureHandlers(target);
671c89
+
671c89
+    if (name in tweenerHandlers) {
671c89
+        let handlers = tweenerHandlers[name];
671c89
+        let handlerIndex = handlers.indexOf(handler);
671c89
+
671c89
+        while (handlerIndex > -1) {
671c89
+            handlers.splice(handlerIndex, 1);
671c89
+            handlerIndex = handlers.indexOf(handler);
671c89
+        }
671c89
+    }
671c89
 }
671c89
 
671c89
 function _actorDestroyed(target) {
671c89
-- 
671c89
2.21.0
671c89
671c89
671c89
From 730f6f7d708a0cbcfcc75e4a1fba8512ac7c4c82 Mon Sep 17 00:00:00 2001
671c89
From: Cosimo Cecchi <cosimo@endlessm.com>
671c89
Date: Sun, 26 May 2019 08:31:07 -0700
671c89
Subject: [PATCH 2/2] windowAttentionHandler: disconnect signals before
671c89
 destruction
671c89
MIME-Version: 1.0
671c89
Content-Type: text/plain; charset=UTF-8
671c89
Content-Transfer-Encoding: 8bit
671c89
671c89
The 'destroy' signal is emitted at the end of the destroy() method.
671c89
However the implementation of destroy() can end up emitting one of the
671c89
signals we connect to on the window, causing us to re-enter destroy
671c89
from its callback.
671c89
That will in turn lead to some objects getting disposed twice, which
671c89
produces a stack trace like the following one.
671c89
671c89
This commit fixes the issue by overriding the destroy() method instead
671c89
of connecting to the signal, which allows us to disconnect the signal
671c89
handlers from the window at an earlier time and avoid re-entrancy.
671c89
671c89
--
671c89
671c89
gnome-shell[1082]: Object Gio.Settings (0x7f0af8143f00), has been already deallocated — impossible to access it. This might be caused by the object having been destroyed from C code using something such as destroy(), dispose(), or remove() vfuncs.
671c89
org.gnome.Shell.desktop[1082]: == Stack trace for context 0x5627f7d1e220 ==
671c89
org.gnome.Shell.desktop[1082]: #0   5627f9e801a8 i   resource:///org/gnome/shell/ui/messageTray.js:238 (7f0aefa9eca0 @ 22)
671c89
org.gnome.Shell.desktop[1082]: #1   5627f9e80108 i   resource:///org/gnome/shell/ui/messageTray.js:802 (7f0aefaa2ee0 @ 28)
671c89
org.gnome.Shell.desktop[1082]: #2   5627f9e80070 i   resource:///org/gnome/shell/ui/windowAttentionHandler.js:79 (7f0aef7b29d0 @ 62)
671c89
org.gnome.Shell.desktop[1082]: #3   7fffa69fbfc0 b   self-hosted:979 (7f0aefa515e0 @ 440)
671c89
org.gnome.Shell.desktop[1082]: #4   5627f9e7ffe0 i   resource:///org/gnome/shell/ui/messageTray.js:121 (7f0aefa9e1f0 @ 71)
671c89
org.gnome.Shell.desktop[1082]: #5   5627f9e7ff38 i   resource:///org/gnome/shell/ui/messageTray.js:1408 (7f0aefaa58b0 @ 22)
671c89
org.gnome.Shell.desktop[1082]: #6   5627f9e7fe80 i   resource:///org/gnome/shell/ui/messageTray.js:1237 (7f0aefaa51f0 @ 729)
671c89
org.gnome.Shell.desktop[1082]: #7   5627f9e7fde8 i   resource:///org/gnome/shell/ui/messageTray.js:1055 (7f0aefaa3d30 @ 124)
671c89
org.gnome.Shell.desktop[1082]: #8   7fffa69ff8e0 b   self-hosted:979 (7f0aefa515e0 @ 440)
671c89
org.gnome.Shell.desktop[1082]: #9   7fffa69ff9d0 b   resource:///org/gnome/gjs/modules/signals.js:142 (7f0aefccb670 @ 386)
671c89
org.gnome.Shell.desktop[1082]: #10   5627f9e7fd58 i   resource:///org/gnome/shell/ui/messageTray.js:479 (7f0aefaa0940 @ 50)
671c89
org.gnome.Shell.desktop[1082]: #11   5627f9e7fcb8 i   resource:///org/gnome/shell/ui/messageTray.js:808 (7f0aefaa2ee0 @ 99)
671c89
org.gnome.Shell.desktop[1082]: #12   5627f9e7fc28 i   resource:///org/gnome/shell/ui/windowAttentionHandler.js:69 (7f0aef7b28b0 @ 13)
671c89
org.gnome.Shell.desktop[1082]: #13   5627f9e7fb80 i   resource:///org/gnome/shell/ui/main.js:566 (7f0aefcd8820 @ 216)
671c89
org.gnome.Shell.desktop[1082]: #14   5627f9e7fad0 i   resource:///org/gnome/shell/ui/windowAttentionHandler.js:103 (7f0aef7b2c10 @ 27)
671c89
org.gnome.Shell.desktop[1082]: #15   5627f9e7fa58 i   resource:///org/gnome/shell/ui/windowAttentionHandler.js:43 (7f0aef7b2700 @ 17)
671c89
org.gnome.Shell.desktop[1082]: #16   7fffa6a03350 b   resource:///org/gnome/gjs/modules/signals.js:142 (7f0aefccb670 @ 386)
671c89
org.gnome.Shell.desktop[1082]: #17   5627f9e7f9d0 i   resource:///org/gnome/shell/ui/messageTray.js:471 (7f0aefaa08b0 @ 22)
671c89
org.gnome.Shell.desktop[1082]: #18   5627f9e7f950 i   resource:///org/gnome/shell/ui/calendar.js:752 (7f0aefaabdc0 @ 22)
671c89
org.gnome.Shell.desktop[1082]: #19   7fffa6a048f0 b   self-hosted:979 (7f0aefa515e0 @ 440)
671c89
org.gnome.Shell.desktop[1082]: == Stack trace for context 0x5627f7d1e220 ==
671c89
org.gnome.Shell.desktop[1082]: #0   5627f9e801a8 i   resource:///org/gnome/shell/ui/messageTray.js:239 (7f0aefa9eca0 @ 42)
671c89
org.gnome.Shell.desktop[1082]: #1   5627f9e80108 i   resource:///org/gnome/shell/ui/messageTray.js:802 (7f0aefaa2ee0 @ 28)
671c89
org.gnome.Shell.desktop[1082]: #2   5627f9e80070 i   resource:///org/gnome/shell/ui/windowAttentionHandler.js:79 (7f0aef7b29d0 @ 62)
671c89
org.gnome.Shell.desktop[1082]: #3   7fffa69fbfc0 b   self-hosted:979 (7f0aefa515e0 @ 440)
671c89
org.gnome.Shell.desktop[1082]: #4   5627f9e7ffe0 i   resource:///org/gnome/shell/ui/messageTray.js:121 (7f0aefa9e1f0 @ 71)
671c89
org.gnome.Shell.desktop[1082]: #5   5627f9e7ff38 i   resource:///org/gnome/shell/ui/messageTray.js:1408 (7f0aefaa58b0 @ 22)
671c89
org.gnome.Shell.desktop[1082]: #6   5627f9e7fe80 i   resource:///org/gnome/shell/ui/messageTray.js:1237 (7f0aefaa51f0 @ 729)
671c89
org.gnome.Shell.desktop[1082]: #7   5627f9e7fde8 i   resource:///org/gnome/shell/ui/messageTray.js:1055 (7f0aefaa3d30 @ 124)
671c89
org.gnome.Shell.desktop[1082]: #8   7fffa69ff8e0 b   self-hosted:979 (7f0aefa515e0 @ 440)
671c89
org.gnome.Shell.desktop[1082]: #9   7fffa69ff9d0 b   resource:///org/gnome/gjs/modules/signals.js:142 (7f0aefccb670 @ 386)
671c89
org.gnome.Shell.desktop[1082]: #10   5627f9e7fd58 i   resource:///org/gnome/shell/ui/messageTray.js:479 (7f0aefaa0940 @ 50)
671c89
org.gnome.Shell.desktop[1082]: #11   5627f9e7fcb8 i   resource:///org/gnome/shell/ui/messageTray.js:808 (7f0aefaa2ee0 @ 99)
671c89
org.gnome.Shell.desktop[1082]: #12   5627f9e7fc28 i   resource:///org/gnome/shell/ui/windowAttentionHandler.js:69 (7f0aef7b28b0 @ 13)
671c89
org.gnome.Shell.desktop[1082]: #13   5627f9e7fb80 i   resource:///org/gnome/shell/ui/main.js:566 (7f0aefcd8820 @ 216)
671c89
org.gnome.Shell.desktop[1082]: #14   5627f9e7fad0 i   resource:///org/gnome/shell/ui/windowAttentionHandler.js:103 (7f0aef7b2c10 @ 27)
671c89
org.gnome.Shell.desktop[1082]: #15   5627f9e7fa58 i   resource:///org/gnome/shell/ui/windowAttentionHandler.js:43 (7f0aef7b2700 @ 17)
671c89
org.gnome.Shell.desktop[1082]: #16   7fffa6a03350 b   resource:///org/gnome/gjs/modules/signals.js:142 (7f0aefccb670 @ 386)
671c89
org.gnome.Shell.desktop[1082]: #17   5627f9e7f9d0 i   resource:///org/gnome/shell/ui/messageTray.js:471 (7f0aefaa08b0 @ 22)
671c89
org.gnome.Shell.desktop[1082]: #18   5627f9e7f950 i   resource:///org/gnome/shell/ui/calendar.js:752 (7f0aefaabdc0 @ 22)
671c89
org.gnome.Shell.desktop[1082]: #19   7fffa6a048f0 b   self-hosted:979 (7f0aefa515e0 @ 440)
671c89
gnome-shell[1082]: g_object_run_dispose: assertion 'G_IS_OBJECT (object)' failed
671c89
gnome-shell[1082]: Object Gio.Settings (0x7f0af8161750), has been already deallocated — impossible to access it. This might be caused by the object having been destroyed from C code using something such as destroy(), dispose(), or remove() vfuncs.
671c89
gnome-shell[1082]: g_object_run_dispose: assertion 'G_IS_OBJECT (object)' failed
671c89
671c89
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/555
671c89
---
671c89
 js/ui/windowAttentionHandler.js | 17 ++++++++---------
671c89
 1 file changed, 8 insertions(+), 9 deletions(-)
671c89
671c89
diff --git a/js/ui/windowAttentionHandler.js b/js/ui/windowAttentionHandler.js
671c89
index abdb8a444..a9a7111ba 100644
671c89
--- a/js/ui/windowAttentionHandler.js
671c89
+++ b/js/ui/windowAttentionHandler.js
671c89
@@ -69,8 +69,6 @@ var Source = class WindowAttentionSource extends MessageTray.Source {
671c89
                                                  () => { this.destroy(); }));
671c89
         this.signalIDs.push(this._window.connect('unmanaged',
671c89
                                                  () => { this.destroy(); }));
671c89
-
671c89
-        this.connect('destroy', this._onDestroy.bind(this));
671c89
     }
671c89
 
671c89
     _sync() {
671c89
@@ -79,13 +77,6 @@ var Source = class WindowAttentionSource extends MessageTray.Source {
671c89
         this.destroy();
671c89
     }
671c89
 
671c89
-    _onDestroy() {
671c89
-        for(let i = 0; i < this.signalIDs.length; i++) {
671c89
-           this._window.disconnect(this.signalIDs[i]);
671c89
-        }
671c89
-        this.signalIDs = [];
671c89
-    }
671c89
-
671c89
     _createPolicy() {
671c89
         if (this._app && this._app.get_app_info()) {
671c89
             let id = this._app.get_id().replace(/\.desktop$/,'');
671c89
@@ -99,6 +90,14 @@ var Source = class WindowAttentionSource extends MessageTray.Source {
671c89
         return this._app.create_icon_texture(size);
671c89
     }
671c89
 
671c89
+    destroy(params) {
671c89
+        for (let i = 0; i < this.signalIDs.length; i++)
671c89
+            this._window.disconnect(this.signalIDs[i]);
671c89
+        this.signalIDs = [];
671c89
+
671c89
+        super.destroy(params);
671c89
+    }
671c89
+
671c89
     open() {
671c89
         Main.activateWindow(this._window);
671c89
     }
671c89
-- 
671c89
2.21.0
671c89