From 7170808d2b10a9d83807f992eea55752ffd59b98 Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Thu, 23 Jan 2020 14:02:17 +0300
Subject: [PATCH] Fix unloading thumbnails in videos.

Fixes #6332.
---
 .../history/view/media/history_view_gif.cpp   | 29 ++++++++++---------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp
index a47da1a94..c94c69484 100644
--- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp
+++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp
@@ -411,19 +411,22 @@ void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms
 				} else {
 					p.drawPixmap(rthumb.topLeft(), normal->pixBlurredSingle(_realParent->fullId(), _thumbw, _thumbh, usew, painth, roundRadius, roundCorners));
 				}
-			} else if (const auto blurred = _data->thumbnailInline()) {
-				p.drawPixmap(rthumb.topLeft(), blurred->pixBlurredSingle(_realParent->fullId(), _thumbw, _thumbh, usew, painth, roundRadius, roundCorners));
-			} else if (!isRound) {
-				const auto roundTop = (roundCorners & RectPart::TopLeft);
-				const auto roundBottom = (roundCorners & RectPart::BottomLeft);
-				const auto margin = inWebPage
-					? st::buttonRadius
-					: st::historyMessageRadius;
-				const auto parts = roundCorners
-					| RectPart::NoTopBottom
-					| (roundTop ? RectPart::Top : RectPart::None)
-					| (roundBottom ? RectPart::Bottom : RectPart::None);
-				App::roundRect(p, rthumb.marginsAdded({ 0, roundTop ? 0 : margin, 0, roundBottom ? 0 : margin }), st::imageBg, roundRadius, parts);
+			} else {
+				_data->loadThumbnail(_realParent->fullId());
+				if (const auto blurred = _data->thumbnailInline()) {
+					p.drawPixmap(rthumb.topLeft(), blurred->pixBlurredSingle(_realParent->fullId(), _thumbw, _thumbh, usew, painth, roundRadius, roundCorners));
+				} else if (!isRound) {
+					const auto roundTop = (roundCorners & RectPart::TopLeft);
+					const auto roundBottom = (roundCorners & RectPart::BottomLeft);
+					const auto margin = inWebPage
+						? st::buttonRadius
+						: st::historyMessageRadius;
+					const auto parts = roundCorners
+						| RectPart::NoTopBottom
+						| (roundTop ? RectPart::Top : RectPart::None)
+						| (roundBottom ? RectPart::Bottom : RectPart::None);
+					App::roundRect(p, rthumb.marginsAdded({ 0, roundTop ? 0 : margin, 0, roundBottom ? 0 : margin }), st::imageBg, roundRadius, parts);
+				}
 			}
 		}
 	}