1 From e883e62a36c342bdf2e31af9d328b10f4ce61112 Mon Sep 17 00:00:00 2001
2 From: Martin Wilck <mwilck@suse.com>
3 Date: Tue, 19 Mar 2019 09:39:36 +0100
4 Subject: [PATCH] Fix shell stack trace when removing icon
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 This fixes stacktraces like this when an application with a tray icon exits:
11 Mar 19 09:09:53 apollon.suse.de gnome-shell[6868]: Object Shell.TrayIcon (0x5588a424ef80), has been already deallocated — impossible to access it. This might be caused by the object having been destroyed from C code using something such as destroy(), dispose(), or remove() vfuncs.
12 Mar 19 09:09:53 apollon.suse.de gnome-shell[6868]: clutter_actor_destroy: assertion 'CLUTTER_IS_ACTOR (self)' failed
13 Mar 19 09:09:53 apollon.suse.de org.gnome.Shell.desktop[6868]: == Stack trace for context 0x5588a17911b0 ==
14 Mar 19 09:09:53 apollon.suse.de org.gnome.Shell.desktop[6868]: #0 5588a2b96d60 i /home/mwilck/.local/share/gnome-shell/extensions/TopIcons@phocean.net/extension.js:127 (7feca5a061f0 @ 92)
16 extension.js | 22 +++++++++++++++++++++-
17 1 file changed, 21 insertions(+), 1 deletion(-)
19 diff --git a/extension.js b/extension.js
20 index 113b8ef..58a0433 100644
23 @@ -31,6 +31,7 @@ const PanelMenu = imports.ui.panelMenu;
24 const ExtensionUtils = imports.misc.extensionUtils;
25 const Me = ExtensionUtils.getCurrentExtension();
26 const Convenience = Me.imports.convenience;
27 +const Config = imports.misc.config;
31 @@ -118,7 +119,8 @@ function onTrayIconRemoved(o, icon) {
32 let parent = icon.get_parent();
36 + if (!parent || !versionAtLeast('3.30', Config.PACKAGE_VERSION))
38 icons.splice(icons.indexOf(icon), 1);
40 if (icons.length === 0)
41 @@ -389,3 +391,21 @@ function setSpacing() {
42 iconsBoxLayout.set_style('spacing: ' + boxLayoutSpacing + 'px; margin_top: 2px; margin_bottom: 2px;');
46 +// Code copied from PanelOSD extension (GPL 2.0)
47 +function versionAtLeast(atleast, current) {
48 + let currentArray = current.split('.');
49 + let major = currentArray[0];
50 + let minor = currentArray[1];
51 + let point = currentArray[2];
52 + let atleastArray = atleast.split('.');
53 + if ((atleastArray[0] < major) ||
54 + (atleastArray[0] == major &&
55 + atleastArray[1] < minor) ||
56 + (atleastArray[0] == major &&
57 + atleastArray[1] == minor) &&
58 + (atleastArray[2] == undefined ||
59 + atleastArray[2] <= point))