Skip to content

Commit c43dd24

Browse files
cgutmanReenigneArcher
authored andcommitted
Don't update tray icon after tray_exit() was called
1 parent 22736c4 commit c43dd24

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- (Linux) Fix udev rules for uinput access not working until after reboot
3232
- (Linux) Fix wrong path in desktop files
3333
- (Tray) Cache icons to avoid possible DRM issues
34+
- (Tray) Fix attempt to update tray icon after it was destroyed
3435
- (Linux) Migrate old config files to new location if env SUNSHINE_MIGRATE_CONFIG=1 is set (automatically set for Flatpak)
3536
- (Linux/Fedora) Re-enable CUDA support and bump to 12.4.0
3637

src/system_tray.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ using namespace std::literals;
4747

4848
// system_tray namespace
4949
namespace system_tray {
50+
static std::atomic<bool> tray_initialized = false;
51+
5052
/**
5153
* @brief Callback for opening the UI from the system tray.
5254
* @param item The tray menu item.
@@ -239,6 +241,7 @@ namespace system_tray {
239241
BOOST_LOG(info) << "System tray created"sv;
240242
}
241243

244+
tray_initialized = true;
242245
while (tray_loop(1) == 0) {
243246
BOOST_LOG(debug) << "System tray loop"sv;
244247
}
@@ -275,6 +278,7 @@ namespace system_tray {
275278
*/
276279
int
277280
end_tray() {
281+
tray_initialized = false;
278282
tray_exit();
279283
return 0;
280284
}
@@ -285,6 +289,10 @@ namespace system_tray {
285289
*/
286290
void
287291
update_tray_playing(std::string app_name) {
292+
if (!tray_initialized) {
293+
return;
294+
}
295+
288296
tray.notification_title = NULL;
289297
tray.notification_text = NULL;
290298
tray.notification_cb = NULL;
@@ -307,6 +315,10 @@ namespace system_tray {
307315
*/
308316
void
309317
update_tray_pausing(std::string app_name) {
318+
if (!tray_initialized) {
319+
return;
320+
}
321+
310322
tray.notification_title = NULL;
311323
tray.notification_text = NULL;
312324
tray.notification_cb = NULL;
@@ -329,6 +341,10 @@ namespace system_tray {
329341
*/
330342
void
331343
update_tray_stopped(std::string app_name) {
344+
if (!tray_initialized) {
345+
return;
346+
}
347+
332348
tray.notification_title = NULL;
333349
tray.notification_text = NULL;
334350
tray.notification_cb = NULL;
@@ -350,6 +366,10 @@ namespace system_tray {
350366
*/
351367
void
352368
update_tray_require_pin() {
369+
if (!tray_initialized) {
370+
return;
371+
}
372+
353373
tray.notification_title = NULL;
354374
tray.notification_text = NULL;
355375
tray.notification_cb = NULL;

0 commit comments

Comments
 (0)