diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index c76378a0c..9265eb53b 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -821,6 +821,8 @@ bool ByDefault() { } void Create(Window::Notifications::System *system) { + static auto ServiceWatcher = CreateServiceWatcher(); + const auto managerSetter = [=] { using ManagerType = Window::Notifications::ManagerType; if ((Core::App().settings().nativeNotifications() || Enforced()) @@ -839,21 +841,34 @@ void Create(Window::Notifications::System *system) { }; if (Gio::Application::get_default()) { + ServiceWatcher = nullptr; + ServiceRegistered = false; + CurrentServerInformation = std::nullopt; + CurrentCapabilities = QStringList{}; managerSetter(); return; } - static const auto ServiceWatcher = CreateServiceWatcher(); - const auto counter = std::make_shared(2); const auto oneReady = [=] { if (!--*counter) { + // GApplication may be created while the reply is received + if (Gio::Application::get_default()) { + Core::App().notifications().createManager(); + return; + } managerSetter(); } }; // snap doesn't allow access when the daemon is not running :( StartServiceAsync([=] { + // GApplication may be created while the reply is received + if (Gio::Application::get_default()) { + Core::App().notifications().createManager(); + return; + } + ServiceRegistered = GetServiceRegistered(); if (!ServiceRegistered) { diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 48693c31c..36853f6df 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -291,6 +291,11 @@ void LaunchGApplication() { nullptr))); app->signal_startup().connect([=] { + // GNotification + InvokeQueued(qApp, [] { + Core::App().notifications().createManager(); + }); + QEventLoop loop; loop.exec(QEventLoop::ApplicationExec); app->quit();