Fixed possible crash from voice messages with ttl.

This commit is contained in:
23rd 2023-12-31 12:34:14 +03:00 committed by John Preston
parent 2a8a74b5b1
commit f53397e26a
1 changed files with 4 additions and 4 deletions

View File

@ -326,13 +326,13 @@ Document::Document(
return (type == AudioMsgId::Type::Voice);
}) | rpl::to_empty
) | rpl::start_with_next([=]() mutable {
_drawTtl = nullptr;
const auto item = _parent->data();
// Destroys this.
ClearMediaAsExpired(_parent->data());
if (lifetime) {
_drawTtl = nullptr;
base::take(lifetime)->destroy();
}
// Destroys this.
ClearMediaAsExpired(item);
}, *lifetime);
_drawTtl = CreateTtlPaintCallback(lifetime, [=] { repaint(); });
@ -437,7 +437,7 @@ QSize Document::countOptimalSize() {
const auto voice = Get<HistoryDocumentVoice>();
if (voice) {
const auto session = &_realParent->history()->session();
if (IsVoiceOncePlayable(_parent->data())
if (_parent->data()->media()->ttlSeconds()
|| (!session->premium()
&& !session->api().transcribes().trialsSupport())) {
voice->transcribe = nullptr;