[gnome-shell] signalTracker: Avoid getting the same owner object proto multiple times
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] signalTracker: Avoid getting the same owner object proto multiple times
- Date: Wed, 6 Jul 2022 17:12:32 +0000 (UTC)
commit ad0f11f02482c28868bcd5dbe0fa67f4f3ad8ca4
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Wed Jul 6 17:50:57 2022 +0200
signalTracker: Avoid getting the same owner object proto multiple times
While untracking an object we used to compute it's proto for each signal
we were disconnecting from, while this is not needed when we're just
iterating over all the same owner signals, so let's add few more
functions to compute an object prototype, and repeat the disconnections
in the simplest way we can.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2366>
js/misc/signalTracker.js | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/js/misc/signalTracker.js b/js/misc/signalTracker.js
index e01bec5b12..9f8a9a70f1 100644
--- a/js/misc/signalTracker.js
+++ b/js/misc/signalTracker.js
@@ -102,11 +102,18 @@ class SignalTracker {
signalData.destroyId = obj.connect_after('destroy', () => this.untrack(obj));
}
- _disconnectSignal(obj, id) {
- const proto = obj instanceof GObject.Object
+ _disconnectSignalForProto(proto, obj, id) {
+ proto['disconnect'].call(obj, id);
+ }
+
+ _getObjectProto(obj) {
+ return obj instanceof GObject.Object
? GObject.Object.prototype
: Object.getPrototypeOf(obj);
- proto['disconnect'].call(obj, id);
+ }
+
+ _disconnectSignal(obj, id) {
+ this._disconnectSignalForProto(this._getObjectProto(obj), obj, id);
}
/**
@@ -129,7 +136,9 @@ class SignalTracker {
const { ownerSignals, destroyId } = this._getSignalData(obj);
this._map.delete(obj);
- ownerSignals.forEach(id => this._disconnectSignal(this._owner, id));
+ const ownerProto = this._getObjectProto(this._owner);
+ ownerSignals.forEach(id =>
+ this._disconnectSignalForProto(ownerProto, this._owner, id));
if (destroyId)
this._disconnectSignal(obj, destroyId);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]