From 2dda044dd1f6a1a52e9e72a8b358e5bb0487489c Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 4 Feb 2022 22:55:36 +0300 Subject: [PATCH] Fix crash in video message without a thumbnail. --- .../history/view/media/history_view_gif.cpp | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index 011a0d086..d1ceecc03 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -473,16 +473,23 @@ void Gif::draw(Painter &p, const PaintContext &context) const { } else if (const auto blurred = _dataMedia->thumbnailInline()) { p.drawPixmap(rthumb.topLeft(), blurred->pixSingle(size, args.blurred())); } else if (!unwrapped) { - const auto roundTop = (roundCorners & RectPart::TopLeft); - const auto roundBottom = (roundCorners & RectPart::BottomLeft); - const auto margin = inWebPage - ? st::roundRadiusSmall - : st::historyMessageRadius; - const auto parts = roundCorners - | RectPart::NoTopBottom - | (roundTop ? RectPart::Top : RectPart::None) - | (roundBottom ? RectPart::Bottom : RectPart::None); - Ui::FillRoundRect(p, rthumb.marginsAdded({ 0, roundTop ? 0 : margin, 0, roundBottom ? 0 : margin }), st->imageBg(), roundRadius, parts); + if (roundRadius == ImageRoundRadius::Ellipse) { + PainterHighQualityEnabler hq(p); + p.setPen(Qt::NoPen); + p.setBrush(st->imageBg()); + p.drawEllipse(rthumb); + } else { + const auto roundTop = (roundCorners & RectPart::TopLeft); + const auto roundBottom = (roundCorners & RectPart::BottomLeft); + const auto margin = inWebPage + ? st::roundRadiusSmall + : st::historyMessageRadius; + const auto parts = roundCorners + | RectPart::NoTopBottom + | (roundTop ? RectPart::Top : RectPart::None) + | (roundBottom ? RectPart::Bottom : RectPart::None); + Ui::FillRoundRect(p, rthumb.marginsAdded({ 0, roundTop ? 0 : margin, 0, roundBottom ? 0 : margin }), st->imageBg(), roundRadius, parts); + } } else { paintPath(p, context, rthumb); }