From 8e8a209aad10e15064494ab01316b75be0abd649 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 27 Jul 2022 23:03:37 +0400 Subject: [PATCH] Guard linux notification inhibition checks --- .../platform/linux/notifications_manager_linux.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index 97b695c265..5c4576207e 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -788,7 +788,7 @@ void Create(Window::Notifications::System *system) { }); } -class Manager::Private { +class Manager::Private : public base::has_weak_ptr { public: using Type = Window::Notifications::CachedUserpics::Type; explicit Private(not_null manager, Type type); @@ -862,9 +862,10 @@ Manager::Private::Private(not_null manager, Type type) return; } - GetInhibited([=](bool result) { + const auto weak = base::make_weak(this); + GetInhibited(crl::guard(weak, [=](bool result) { _inhibited = result; - }); + })); _inhibitedSignalId = _dbusConnection->signal_subscribe( [=]( @@ -882,10 +883,14 @@ Manager::Private::Private(not_null manager, Type type) return; } - _inhibited = GlibVariantCast( + const auto inhibited = GlibVariantCast( GlibVariantCast< std::map >(parameters.get_child(1)).at("Inhibited")); + + crl::on_main(weak, [=] { + _inhibited = inhibited; + }); }); }, std::string(kService),