Fix crash in MediaView with thumbless GIFs.

This commit is contained in:
John Preston 2019-02-01 10:20:38 +03:00
parent b28e374e06
commit 4f3263d979
2 changed files with 13 additions and 5 deletions

View File

@ -349,7 +349,7 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, TimeM
} }
if (const auto normal = _data->thumbnail()) { if (const auto normal = _data->thumbnail()) {
if (normal->loaded()) { if (normal->loaded()) {
p.drawPixmap(rthumb.topLeft(), _data->thumbnail()->pixSingle(_realParent->fullId(), _thumbw, _thumbh, usew, painth, roundRadius, roundCorners)); p.drawPixmap(rthumb.topLeft(), normal->pixSingle(_realParent->fullId(), _thumbw, _thumbh, usew, painth, roundRadius, roundCorners));
} else if (const auto blurred = _data->thumbnailInline()) { } else if (const auto blurred = _data->thumbnailInline()) {
p.drawPixmap(rthumb.topLeft(), blurred->pixBlurredSingle(_realParent->fullId(), _thumbw, _thumbh, usew, painth, roundRadius, roundCorners)); p.drawPixmap(rthumb.topLeft(), blurred->pixBlurredSingle(_realParent->fullId(), _thumbw, _thumbh, usew, painth, roundRadius, roundCorners));
} }

View File

@ -1798,10 +1798,14 @@ void MediaView::initAnimation() {
} else if (_doc->dimensions.width() && _doc->dimensions.height()) { } else if (_doc->dimensions.width() && _doc->dimensions.height()) {
auto w = _doc->dimensions.width(); auto w = _doc->dimensions.width();
auto h = _doc->dimensions.height(); auto h = _doc->dimensions.height();
_current = _doc->thumbnail()->pixNoCache(fileOrigin(), w, h, VideoThumbOptions(_doc), w / cIntRetinaFactor(), h / cIntRetinaFactor()); _current = (_doc->hasThumbnail()
? _doc->thumbnail()
: Image::Blank().get())->pixNoCache(fileOrigin(), w, h, VideoThumbOptions(_doc), w / cIntRetinaFactor(), h / cIntRetinaFactor());
_current.setDevicePixelRatio(cRetinaFactor()); _current.setDevicePixelRatio(cRetinaFactor());
} else { } else {
_current = _doc->thumbnail()->pixNoCache(fileOrigin(), _doc->thumbnail()->width(), _doc->thumbnail()->height(), VideoThumbOptions(_doc), st::mediaviewFileIconSize, st::mediaviewFileIconSize); _current = (_doc->hasThumbnail()
? _doc->thumbnail()
: Image::Blank().get())->pixNoCache(fileOrigin(), _doc->thumbnail()->width(), _doc->thumbnail()->height(), VideoThumbOptions(_doc), st::mediaviewFileIconSize, st::mediaviewFileIconSize);
} }
} }
@ -1814,10 +1818,14 @@ void MediaView::createClipReader() {
if (_doc->dimensions.width() && _doc->dimensions.height()) { if (_doc->dimensions.width() && _doc->dimensions.height()) {
int w = _doc->dimensions.width(); int w = _doc->dimensions.width();
int h = _doc->dimensions.height(); int h = _doc->dimensions.height();
_current = _doc->thumbnail()->pixNoCache(fileOrigin(), w, h, VideoThumbOptions(_doc), w / cIntRetinaFactor(), h / cIntRetinaFactor()); _current = (_doc->hasThumbnail()
? _doc->thumbnail()
: Image::Blank().get())->pixNoCache(fileOrigin(), w, h, VideoThumbOptions(_doc), w / cIntRetinaFactor(), h / cIntRetinaFactor());
_current.setDevicePixelRatio(cRetinaFactor()); _current.setDevicePixelRatio(cRetinaFactor());
} else { } else {
_current = _doc->thumbnail()->pixNoCache(fileOrigin(), _doc->thumbnail()->width(), _doc->thumbnail()->height(), VideoThumbOptions(_doc), st::mediaviewFileIconSize, st::mediaviewFileIconSize); _current = (_doc->hasThumbnail()
? _doc->thumbnail()
: Image::Blank().get())->pixNoCache(fileOrigin(), _doc->thumbnail()->width(), _doc->thumbnail()->height(), VideoThumbOptions(_doc), st::mediaviewFileIconSize, st::mediaviewFileIconSize);
} }
auto mode = (_doc->isVideoFile() || _doc->isVideoMessage()) auto mode = (_doc->isVideoFile() || _doc->isVideoMessage())
? Media::Clip::Reader::Mode::Video ? Media::Clip::Reader::Mode::Video