2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Let [Photo|Document]Media outlive message view.

This commit is contained in:
John Preston
2020-05-26 18:32:38 +04:00
parent 700d3db4cc
commit dbb46ce9b0
15 changed files with 48 additions and 27 deletions

View File

@@ -1601,13 +1601,9 @@ void DocumentData::collectLocalData(not_null<DocumentData*> local) {
_owner->cache().copyIfEmpty(local->cacheKey(), cacheKey());
if (const auto localMedia = local->activeMediaView()) {
const auto media = createMediaView();
auto media = createMediaView();
media->collectLocalData(localMedia.get());
// Keep DocumentMedia alive for some more time.
// NB! This allows DocumentMedia to outlive Main::Session!
// In case this is a problem this code should be rewritten.
crl::on_main(&session(), [media] {});
_owner->keepAlive(std::move(media));
}
if (!local->_location.inMediaCache() && !local->_location.isEmpty()) {
_location = local->_location;