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

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