Utils: Check system tray exists before trying to use it

Fixes https://github.com/obsproject/obs-studio/issues/9991
This commit is contained in:
Richard Stanway 2023-12-14 21:14:38 +01:00 committed by tt2468
parent f48fcc06ec
commit 0189c3a3f5

View File

@ -116,11 +116,12 @@ void Utils::Platform::SendTrayNotification(QSystemTrayIcon::MessageIcon icon, QS
obs_queue_task(
OBS_TASK_UI,
[](void *param) {
void *systemTrayPtr = obs_frontend_get_system_tray();
auto systemTray = static_cast<QSystemTrayIcon *>(systemTrayPtr);
auto notification = static_cast<SystemTrayNotification *>(param);
systemTray->showMessage(notification->title, notification->body, notification->icon);
void *systemTrayPtr = obs_frontend_get_system_tray();
if (systemTrayPtr) {
auto systemTray = static_cast<QSystemTrayIcon *>(systemTrayPtr);
systemTray->showMessage(notification->title, notification->body, notification->icon);
}
delete notification;
},
(void *)notification, false);