From 66fc9b38df687bd4d1efeb339a49790d7f7a58e8 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 3 Mar 2025 10:47:02 +0000 Subject: [PATCH] Fix a race condition with asynchronous notification sending --- .../platform/linux/notifications_manager_linux.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index 835aceffa..67abd46b8 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -141,7 +141,7 @@ bool UseGNotification() { } // namespace -class Manager::Private { +class Manager::Private : public base::has_weak_ptr { public: explicit Private(not_null manager); @@ -750,7 +750,7 @@ void Manager::Private::showNotification( const auto callbackWrap = gi::unwrap( Gio::AsyncReadyCallback( - crl::guard(weak, [=]( + crl::guard(this, [=]( GObject::Object, Gio::AsyncResult res) { auto &sandbox = Core::Sandbox::Instance(); @@ -767,6 +767,13 @@ void Manager::Private::showNotification( return; } + if (!weak) { + _interface.call_close_notification( + std::get<1>(*result), + nullptr); + return; + } + weak->id = std::get<1>(*result); }); })),