mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
Fixed possible crash on deleting of media message with ttl.
This commit is contained in:
parent
a2c0491ae0
commit
46ddc7364c
2 changed files with 12 additions and 7 deletions
|
@ -309,18 +309,20 @@ Document::Document(
|
|||
}, *lifetime);
|
||||
_drawTtl = CreateTtlPaintCallback(lifetime, [=] { repaint(); });
|
||||
} else if (!_parent->data()->out()) {
|
||||
const auto &data = &_parent->data()->history()->owner();
|
||||
_parent->data()->removeFromSharedMediaIndex();
|
||||
setDocumentLinks(_data, realParent, [=] {
|
||||
_openl = nullptr;
|
||||
|
||||
auto lifetime = std::make_shared<rpl::lifetime>();
|
||||
TTLVoiceStops(fullId) | rpl::start_with_next([=]() mutable {
|
||||
const auto item = _parent->data();
|
||||
if (lifetime) {
|
||||
base::take(lifetime)->destroy();
|
||||
}
|
||||
// Destroys this.
|
||||
ClearMediaAsExpired(item);
|
||||
if (const auto item = data->message(fullId)) {
|
||||
// Destroys this.
|
||||
ClearMediaAsExpired(item);
|
||||
}
|
||||
}, *lifetime);
|
||||
|
||||
return false;
|
||||
|
|
|
@ -150,17 +150,20 @@ Gif::Gif(
|
|||
_drawTtl = CreateTtlPaintCallback([=] { repaint(); });
|
||||
}
|
||||
const auto fullId = _realParent->fullId();
|
||||
const auto &data = &_parent->data()->history()->owner();
|
||||
const auto isOut = _parent->data()->out();
|
||||
_parent->data()->removeFromSharedMediaIndex();
|
||||
setDocumentLinks(_data, realParent, [=] {
|
||||
auto lifetime = std::make_shared<rpl::lifetime>();
|
||||
TTLVoiceStops(fullId) | rpl::start_with_next([=]() mutable {
|
||||
const auto item = _parent->data();
|
||||
if (lifetime) {
|
||||
base::take(lifetime)->destroy();
|
||||
}
|
||||
if (!item->out()) {
|
||||
// Destroys this.
|
||||
ClearMediaAsExpired(item);
|
||||
if (!isOut) {
|
||||
if (const auto item = data->message(fullId)) {
|
||||
// Destroys this.
|
||||
ClearMediaAsExpired(item);
|
||||
}
|
||||
}
|
||||
}, *lifetime);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue