Fix a race condition with asynchronous notification sending

This commit is contained in:
Ilya Fedin 2025-03-03 10:47:02 +00:00 committed by John Preston
parent 5dbe429e6b
commit 66fc9b38df

View file

@ -141,7 +141,7 @@ bool UseGNotification() {
} // namespace } // namespace
class Manager::Private { class Manager::Private : public base::has_weak_ptr {
public: public:
explicit Private(not_null<Manager*> manager); explicit Private(not_null<Manager*> manager);
@ -750,7 +750,7 @@ void Manager::Private::showNotification(
const auto callbackWrap = gi::unwrap( const auto callbackWrap = gi::unwrap(
Gio::AsyncReadyCallback( Gio::AsyncReadyCallback(
crl::guard(weak, [=]( crl::guard(this, [=](
GObject::Object, GObject::Object,
Gio::AsyncResult res) { Gio::AsyncResult res) {
auto &sandbox = Core::Sandbox::Instance(); auto &sandbox = Core::Sandbox::Instance();
@ -767,6 +767,13 @@ void Manager::Private::showNotification(
return; return;
} }
if (!weak) {
_interface.call_close_notification(
std::get<1>(*result),
nullptr);
return;
}
weak->id = std::get<1>(*result); weak->id = std::get<1>(*result);
}); });
})), })),