signalTracker: Use connect_after to track 'destroy'

The 'destroy' signal currently doesn't work with connectObject(),
because the handler is only connected after the signal tracker's
own destroy handler, which disconnects all handlers.

Address this by using connect_after for the cleanup handler, so
that other destroy handlers run before it (unless they also use
ConnectFlags.AFTER, but well *shrug*).

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2221>
This commit is contained in:
Florian Müllner 2022-03-04 23:34:59 +01:00 committed by Marge Bot
parent 70a896ec45
commit 7b0a94b246

View File

@ -32,7 +32,7 @@ class SignalTracker {
*/
constructor(owner) {
if (this._hasDestroySignal(owner))
this._ownerDestroyId = owner.connect('destroy', () => this.clear());
this._ownerDestroyId = owner.connect_after('destroy', () => this.clear());
this._owner = owner;
this._map = new Map();
@ -73,7 +73,7 @@ class SignalTracker {
const signalData = this._getSignalData(obj);
if (signalData.destroyId)
return;
signalData.destroyId = obj.connect('destroy', () => this.untrack(obj));
signalData.destroyId = obj.connect_after('destroy', () => this.untrack(obj));
}
_disconnectSignal(obj, id) {