From e2a97e2ae975edde8770a538a91e8f84066d5c3d Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 16 Jun 2021 15:32:21 +0400 Subject: [PATCH] Fix possible crash in media viewer. --- .../media/view/media_view_overlay_widget.cpp | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index db7e50645..8d276b10d 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -2442,20 +2442,19 @@ void OverlayWidget::displayDocument( refreshCaption(item); _docIconRect = QRect((width() - st::mediaviewFileIconSize) / 2, (height() - st::mediaviewFileIconSize) / 2, st::mediaviewFileIconSize, st::mediaviewFileIconSize); - if (documentBubbleShown()) { - if (!_document || !_document->hasThumbnail()) { - int32 colorIndex = documentColorIndex(_document, _docExt); - _docIconColor = documentColor(colorIndex); - const style::icon *(thumbs[]) = { &st::mediaviewFileBlue, &st::mediaviewFileGreen, &st::mediaviewFileRed, &st::mediaviewFileYellow }; - _docIcon = thumbs[colorIndex]; + int32 colorIndex = documentColorIndex(_document, _docExt); + _docIconColor = documentColor(colorIndex); + const style::icon *(thumbs[]) = { &st::mediaviewFileBlue, &st::mediaviewFileGreen, &st::mediaviewFileRed, &st::mediaviewFileYellow }; + _docIcon = thumbs[colorIndex]; - int32 extmaxw = (st::mediaviewFileIconSize - st::mediaviewFileExtPadding * 2); - _docExtWidth = st::mediaviewFileExtFont->width(_docExt); - if (_docExtWidth > extmaxw) { - _docExt = st::mediaviewFileExtFont->elided(_docExt, extmaxw, Qt::ElideMiddle); - _docExtWidth = st::mediaviewFileExtFont->width(_docExt); - } - } else { + int32 extmaxw = (st::mediaviewFileIconSize - st::mediaviewFileExtPadding * 2); + _docExtWidth = st::mediaviewFileExtFont->width(_docExt); + if (_docExtWidth > extmaxw) { + _docExt = st::mediaviewFileExtFont->elided(_docExt, extmaxw, Qt::ElideMiddle); + _docExtWidth = st::mediaviewFileExtFont->width(_docExt); + } + if (documentBubbleShown()) { + if (_document && _document->hasThumbnail()) { _document->loadThumbnail(fileOrigin()); const auto tw = _documentMedia->thumbnailSize().width(); const auto th = _documentMedia->thumbnailSize().height();