2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

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
class Manager::Private {
class Manager::Private : public base::has_weak_ptr {
public:
explicit Private(not_null<Manager*> 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);
});
})),