From e1ca9a8029f89d9c3be0506c5aca5f2646246f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20L?= Date: Wed, 14 Mar 2018 00:05:43 +0100 Subject: [PATCH] notifications: check if system tray is available before notifying --- src/Utils.cpp | 8 +++++++- src/Utils.h | 2 -- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Utils.cpp b/src/Utils.cpp index 05a0300e8..2c66db3ca 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -308,13 +308,19 @@ QString Utils::OBSVersionString() { QSystemTrayIcon* Utils::GetTrayIcon() { QMainWindow* main = (QMainWindow*)obs_frontend_get_main_window(); + if (!main) return nullptr; + return main->findChildren().first(); } void Utils::SysTrayNotify(QString &text, QSystemTrayIcon::MessageIcon icon, QString title) { - if (!Config::Current()->AlertsEnabled || !QSystemTrayIcon::supportsMessages()) + if (!Config::Current()->AlertsEnabled || + !QSystemTrayIcon::isSystemTrayAvailable() || + !QSystemTrayIcon::supportsMessages()) + { return; + } QSystemTrayIcon* trayIcon = GetTrayIcon(); if (trayIcon) diff --git a/src/Utils.h b/src/Utils.h index f1dd8ac17..c494efba7 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -47,8 +47,6 @@ class Utils { static obs_data_array_t* GetScenes(); static obs_data_t* GetSceneData(obs_source_t* source); - static obs_data_array_t* GetProfiles(); - static QSpinBox* GetTransitionDurationControl(); static int GetTransitionDuration(); static void SetTransitionDuration(int ms);