From 93a1fd0b604eefb1531e110b9bf5d76aeccab500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 23 Jan 2015 15:41:33 +0100 Subject: [PATCH] window-list: Fix for "app-less" windows While rare, it is possible to have a window not associated with any app (not even a fake window-based one). We currently throw an error when trying to set the icon for such a window, so handle this case and use a fallback icon instead of the app icon. https://bugzilla.gnome.org/show_bug.cgi?id=743401 --- extensions/window-list/extension.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js index e298caa1..5c44272f 100644 --- a/extensions/window-list/extension.js +++ b/extensions/window-list/extension.js @@ -141,19 +141,17 @@ const WindowTitle = new Lang.Class({ this._metaWindow = metaWindow; this.actor = new St.BoxLayout({ style_class: 'window-button-box' }); - let app = Shell.WindowTracker.get_default().get_window_app(metaWindow); - this._icon = new St.Bin({ style_class: 'window-button-icon', - child: app.create_icon_texture(ICON_TEXTURE_SIZE) }); + this._icon = new St.Bin({ style_class: 'window-button-icon' }); this.actor.add(this._icon); this._label = new St.Label(); this.actor.add(this._label); this._textureCache = St.TextureCache.get_default(); this._iconThemeChangedId = - this._textureCache.connect('icon-theme-changed', Lang.bind(this, - function() { - this._icon.child = app.create_icon_texture(ICON_TEXTURE_SIZE); - })); + this._textureCache.connect('icon-theme-changed', + Lang.bind(this, this._updateIcon)); + this._updateIcon(); + this.actor.connect('destroy', Lang.bind(this, this._onDestroy)); this._notifyTitleId = @@ -177,6 +175,15 @@ const WindowTitle = new Lang.Class({ this._label.text = this._metaWindow.title; }, + _updateIcon: function() { + let app = Shell.WindowTracker.get_default().get_window_app(this._metaWindow); + if (app) + this._icon.child = app.create_icon_texture(ICON_TEXTURE_SIZE); + else + this._icon.child = new St.Icon({ icon_name: 'icon-missing', + icon_size: ICON_TEXTURE_SIZE }); + }, + _onDestroy: function() { this._textureCache.disconnect(this._iconThemeChangedId); this._metaWindow.disconnect(this._notifyTitleId);