From fcadc02a293f14a3e88a85744fae45decdf79915 Mon Sep 17 00:00:00 2001 From: borgmanJeremy <46930769+borgmanJeremy@users.noreply.github.com> Date: Tue, 28 Dec 2021 08:43:17 -0600 Subject: [PATCH] Fix recursive static init (#2196) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Removed default config for abstract logger that sends a system notification, also cleaned up a useless ifdef * Send notifications from event loop on Win and Mac (#2197) Signed-off-by: Haris Gušić Co-authored-by: Haris Gušić --- src/core/controller.cpp | 2 -- src/utils/systemnotification.cpp | 9 ++++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/core/controller.cpp b/src/core/controller.cpp index 8b232c51..08bbd3f5 100644 --- a/src/core/controller.cpp +++ b/src/core/controller.cpp @@ -519,12 +519,10 @@ void Controller::enableTrayIcon() void Controller::disableTrayIcon() { -#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) || defined(Q_OS_MACOS) if (m_trayIcon) { m_trayIcon->hide(); } ConfigHandler().setDisabledTrayIcon(true); -#endif } void Controller::sendTrayNotification(const QString& text, diff --git a/src/utils/systemnotification.cpp b/src/utils/systemnotification.cpp index d1a5deb0..c4be02b3 100644 --- a/src/utils/systemnotification.cpp +++ b/src/utils/systemnotification.cpp @@ -40,7 +40,14 @@ void SystemNotification::sendMessage(const QString& text, } #if defined(Q_OS_MACOS) || defined(Q_OS_WIN) - Controller::getInstance()->sendTrayNotification(text, title, timeout); + QMetaObject::invokeMethod( + this, + [&]() { + // The call is queued to avoid recursive static initialization of + // Controller and ConfigHandler. + Controller::getInstance()->sendTrayNotification(text, title, timeout); + }, + Qt::QueuedConnection); #else QList args; QVariantMap hintsMap;