diff --git a/js/ui/background.js b/js/ui/background.js index 1f7c5e57200c20462141a44167f1d39a0379a541..d6936b25cfd943dd3f54e0a76ee70e3e2d8048b1 100644 --- a/js/ui/background.js +++ b/js/ui/background.js @@ -245,6 +245,13 @@ var Background = GObject.registerClass({ this.isLoaded = false; this._clock = new GnomeDesktop.WallClock(); + /* + * Extra _clock.ref() is required to stop toggle references from + * triggering garbage collection every time the clock emits a tick, + * even though that's a notify::clock and not a notify::timezone. + * The reference still toggles internally within Glib. + */ + this._clock.ref(); this._timezoneChangedId = this._clock.connect('notify::timezone', () => { if (this._animation) @@ -280,7 +287,10 @@ var Background = GObject.registerClass({ this._clock.disconnect(this._timezoneChangedId); this._timezoneChangedId = 0; - this._clock = null; + if (this._clock) { + this._clock.unref(); + this._clock = null; + } if (this._prepareForSleepId != 0) LoginManager.getLoginManager().disconnect(this._prepareForSleepId); diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js index 6edd790a05847dfad6d11aadc5e54c36dd395691..e80987e307364a07008a6df607713e22c06f1971 100644 --- a/js/ui/dateMenu.js +++ b/js/ui/dateMenu.js @@ -876,11 +876,24 @@ class DateMenuButton extends PanelMenu.Button { // Done with hbox for calendar and event list this._clock = new GnomeDesktop.WallClock(); + /* + * Extra _clock.ref() is required to stop toggle references from + * triggering garbage collection every time the clock emits a tick. + */ + this._clock.ref(); this._clock.bind_property('clock', this._clockDisplay, 'text', GObject.BindingFlags.SYNC_CREATE); - this._clock.connect('notify::timezone', this._updateTimeZone.bind(this)); + this._timezoneChangedId = this._clock.connect('notify::timezone', this._updateTimeZone.bind(this)); Main.sessionMode.connect('updated', this._sessionUpdated.bind(this)); this._sessionUpdated(); + + this.connect('destroy', this._onDestroy.bind(this)); + } + + _onDestroy() { + this._clock.disconnect(this._timezoneChangedId); + this._clock.unref(); + this._clock = null; } _getEventSource() { diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js index 3ef6aa90f053d75d6db50e30c6f8bb58079e8ae6..eed2f8f86a7df536adaa12c6f989d1ca1cbb4753 100644 --- a/js/ui/unlockDialog.js +++ b/js/ui/unlockDialog.js @@ -338,7 +338,12 @@ class UnlockDialogClock extends St.BoxLayout { this.add_child(this._hint); this._wallClock = new GnomeDesktop.WallClock({ time_only: true }); - this._wallClock.connect('notify::clock', this._updateClock.bind(this)); + /* + * Extra _wallClock.ref() is required to stop toggle references from + * triggering garbage collection every time the clock emits a tick. + */ + this._wallClock.ref(); + this._notifyClockId = this._wallClock.connect('notify::clock', this._updateClock.bind(this)); this._seat = Clutter.get_default_backend().get_default_seat(); this._touchModeChangedId = this._seat.connect('notify::touch-mode', @@ -379,7 +384,9 @@ class UnlockDialogClock extends St.BoxLayout { } _onDestroy() { - this._wallClock.run_dispose(); + this._wallClock.disconnect(this._notifyClockId); + this._wallClock.unref(); + this._wallClock = null; this._seat.disconnect(this._touchModeChangedId); this._idleMonitor.remove_watch(this._idleWatchId);