Commit bb72bf5
committed
Fix duplicated and crashing DBus tray icon
Two problems in DBusTrayIconImpl, both visible on GNOME with the
appindicator/KStatusNotifierItem extension.
Duplicated icon: the StatusNotifierItem object was exported on the
connection before the well-known name was requested, and the name was
released and re-requested (with a new instance id) every time the
StatusNotifierWatcher came back. A host that scans the bus for items -
gnome-shell-extension-appindicator does this whenever it starts - finds
the object on a connection which does not own an
org.kde.StatusNotifierItem-* name, so it registers the item under the
unique connection name, and the RegisterStatusNotifierItem call that
follows adds a second entry for the same process. The object is now
exported only while the name is owned, the name keeps its instance id
for the lifetime of the tray icon, and it is no longer dropped and
retaken when the watcher restarts.
Hiding still releases the name: that is the only part of it a host can
observe, since the item stays Active and unexporting the object is
silent on the bus. It now happens after the object has been unexported,
so the "object exported while the name is not owned" window which
produces the duplicate never opens.
Crash on disposal: WatchAsync is an async void method awaiting a
cancellable delay. Dispose cancels the token and only then sets
_isDisposed, but the continuation is posted to the dispatcher and runs
after Dispose has returned, so neither exception filter matches and the
OperationCanceledException is rethrown on the dispatcher, terminating
the process. The cancellation is now handled explicitly. CreateTrayIcon
is async void as well and takes the process down the same way when a
DBus call fails (for example when the watcher disappears while the item
is being registered), so its body is guarded too.1 parent 845b81d commit bb72bf5
1 file changed
Lines changed: 59 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| 56 | + | |
55 | 57 | | |
56 | | - | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
96 | 102 | | |
97 | 103 | | |
98 | 104 | | |
| |||
110 | 116 | | |
111 | 117 | | |
112 | 118 | | |
113 | | - | |
114 | | - | |
115 | 119 | | |
116 | 120 | | |
117 | 121 | | |
| |||
124 | 128 | | |
125 | 129 | | |
126 | 130 | | |
127 | | - | |
| 131 | + | |
128 | 132 | | |
129 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
130 | 140 | | |
131 | | - | |
| 141 | + | |
132 | 142 | | |
133 | | - | |
| 143 | + | |
134 | 144 | | |
135 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
136 | 148 | | |
137 | | - | |
138 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
139 | 156 | | |
140 | | - | |
141 | | - | |
142 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
143 | 160 | | |
144 | | - | |
145 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
146 | 172 | | |
147 | 173 | | |
148 | 174 | | |
149 | 175 | | |
150 | 176 | | |
151 | 177 | | |
152 | 178 | | |
153 | | - | |
154 | 179 | | |
155 | 180 | | |
156 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
157 | 199 | | |
158 | 200 | | |
159 | 201 | | |
160 | 202 | | |
| 203 | + | |
161 | 204 | | |
162 | 205 | | |
163 | 206 | | |
| |||
215 | 258 | | |
216 | 259 | | |
217 | 260 | | |
| 261 | + | |
218 | 262 | | |
219 | 263 | | |
220 | 264 | | |
| |||
0 commit comments