@@ -47,6 +47,8 @@ using namespace std::literals;
47
47
48
48
// system_tray namespace
49
49
namespace system_tray {
50
+ static std::atomic<bool > tray_initialized = false ;
51
+
50
52
/* *
51
53
* @brief Callback for opening the UI from the system tray.
52
54
* @param item The tray menu item.
@@ -239,6 +241,7 @@ namespace system_tray {
239
241
BOOST_LOG (info) << " System tray created" sv;
240
242
}
241
243
244
+ tray_initialized = true ;
242
245
while (tray_loop (1 ) == 0 ) {
243
246
BOOST_LOG (debug) << " System tray loop" sv;
244
247
}
@@ -275,6 +278,7 @@ namespace system_tray {
275
278
*/
276
279
int
277
280
end_tray () {
281
+ tray_initialized = false ;
278
282
tray_exit ();
279
283
return 0 ;
280
284
}
@@ -285,6 +289,10 @@ namespace system_tray {
285
289
*/
286
290
void
287
291
update_tray_playing (std::string app_name) {
292
+ if (!tray_initialized) {
293
+ return ;
294
+ }
295
+
288
296
tray.notification_title = NULL ;
289
297
tray.notification_text = NULL ;
290
298
tray.notification_cb = NULL ;
@@ -307,6 +315,10 @@ namespace system_tray {
307
315
*/
308
316
void
309
317
update_tray_pausing (std::string app_name) {
318
+ if (!tray_initialized) {
319
+ return ;
320
+ }
321
+
310
322
tray.notification_title = NULL ;
311
323
tray.notification_text = NULL ;
312
324
tray.notification_cb = NULL ;
@@ -329,6 +341,10 @@ namespace system_tray {
329
341
*/
330
342
void
331
343
update_tray_stopped (std::string app_name) {
344
+ if (!tray_initialized) {
345
+ return ;
346
+ }
347
+
332
348
tray.notification_title = NULL ;
333
349
tray.notification_text = NULL ;
334
350
tray.notification_cb = NULL ;
@@ -350,6 +366,10 @@ namespace system_tray {
350
366
*/
351
367
void
352
368
update_tray_require_pin () {
369
+ if (!tray_initialized) {
370
+ return ;
371
+ }
372
+
353
373
tray.notification_title = NULL ;
354
374
tray.notification_text = NULL ;
355
375
tray.notification_cb = NULL ;
0 commit comments