signalTracker: Don't try to create a new SignalTracker for disconnecting

After the next commit, when some classes, such as PopupMenuManager try
to disconnect via a destroy handler, the SignalTracker might have
already been destroyed, so trying to get it from the SignalManager will
cause it to create a new one, which will then try to connect to the
destroy signal of the already destroyed object.

This could for example be triggered by changing backgrounds.

Fix this by not doing anything in disconnectObject if there is no
SignalTracker for that object.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2466>
This commit is contained in:
Sebastian Keller 2022-08-29 04:19:28 +02:00 committed by Marge Bot
parent d57953ad94
commit 54ee728aa0

View File

@ -57,6 +57,14 @@ class SignalManager {
}
return signalTracker;
}
/**
* @param {Object} obj - object to get signal tracker for
* @returns {?SignalTracker} - the signal tracker for object if it exists
*/
maybeGetSignalTracker(obj) {
return this._signalTrackers.get(obj) ?? null;
}
}
class SignalTracker {
@ -225,7 +233,7 @@ function connectObject(thisObj, ...args) {
* @returns {void}
*/
function disconnectObject(thisObj, obj) {
SignalManager.getDefault().getSignalTracker(thisObj).untrack(obj);
SignalManager.getDefault().maybeGetSignalTracker(thisObj)?.untrack(obj);
}
/**