Skip to content

Commit d142823

Browse files
committed
signalTracker.js: Don't track "destroy" for non-ClutterActors.
The CinnamonWM class (global.window_manager) has a "destroy" signal which maps to windows being destroyed, not its own class, but this gets caught when using connectObject for signal handling, causing all handlers to be released when the class emits destroy. ClutterActors are really the only thing in Cinnamon's runtime that will have a destroy signal, so just do an instance type check.
1 parent 5b65946 commit d142823

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

js/misc/signalTracker.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
/* exported addObjectSignalMethods */
22
const GObject = imports.gi.GObject;
3+
const Clutter = imports.gi.Clutter;
34

45
/**
56
* @private
67
* @param {Object} obj - an object
7-
* @returns {bool} - true if obj has a 'destroy' GObject signal
8+
* @returns {bool} - true if obj's 'destroy' signal indicates its own lifecycle
9+
* end (i.e. obj is a Clutter.Actor or subclass).
10+
*
11+
* Some classes (e.g. Cinnamon.WM) declare a 'destroy' signal with
12+
* domain-specific semantics unrelated to the emitter's own lifetime, so we
13+
* only treat the signal as lifecycle for Clutter actors.
814
*/
9-
function _hasDestroySignal(obj) {
10-
return obj instanceof GObject.Object &&
11-
GObject.signal_lookup('destroy', obj);
15+
function _hasLifecycleDestroy(obj) {
16+
return obj instanceof Clutter.Actor;
1217
}
1318

1419
var TransientSignalHolder = GObject.registerClass(
@@ -20,7 +25,7 @@ class TransientSignalHolder extends GObject.Object {
2025
constructor(owner) {
2126
super();
2227

23-
if (_hasDestroySignal(owner))
28+
if (_hasLifecycleDestroy(owner))
2429
owner.connectObject('destroy', () => this.destroy(), this);
2530
}
2631

@@ -84,7 +89,7 @@ class SignalTracker {
8489
* @param {Object=} owner - object that owns the tracker
8590
*/
8691
constructor(owner) {
87-
if (_hasDestroySignal(owner))
92+
if (_hasLifecycleDestroy(owner))
8893
this._ownerDestroyId = owner.connect_after('destroy', () => this.clear());
8994

9095
this._owner = owner;
@@ -152,7 +157,7 @@ class SignalTracker {
152157
* @returns {void}
153158
*/
154159
track(obj, ...handlerIds) {
155-
if (_hasDestroySignal(obj))
160+
if (_hasLifecycleDestroy(obj))
156161
this._trackDestroy(obj);
157162

158163
this._getSignalData(obj).ownerSignals.push(...handlerIds);

0 commit comments

Comments
 (0)