From b6bf07ef6ab3bebe4fcc57d3b7571180ff1a9fe2 Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Feb 09 2019 05:23:15 +0000 Subject: Improve tracking of existing logos We currently track all logos we create in an array, so we can destroy them when no longer needed. However it is possible that the corresponding actor has already been destroyed (for instance when a monitor is unplugged), re- sulting in warnings with newer gjs versions. Fix this by tracking logos in a Set and remove any logo whose actor is destroyed. https://pagure.io/background-logo-extension/issue/8 --- diff --git a/extension.js b/extension.js index b06751d..e99c21e 100644 --- a/extension.js +++ b/extension.js @@ -206,7 +206,7 @@ class Extension { constructor() { this._monitorsChangedId = 0; this._startupPreparedId = 0; - this._logos = []; + this._logos = new Set(); } _forEachBackgroundManager(func) { @@ -217,13 +217,16 @@ class Extension { _addLogo() { this._destroyLogo(); this._forEachBackgroundManager(bgManager => { - this._logos.push(new BackgroundLogo(bgManager)); + let logo = new BackgroundLogo(bgManager); + logo.actor.connect('destroy', () => { + this._logos.delete(logo); + }); + this._logos.add(logo); }); } _destroyLogo() { this._logos.forEach(l => { l.actor.destroy(); }); - this._logos = []; } enable() {