From 0d853c9393ad48376cc2479ef2ff23e151e56fcf Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 6 Jan 2026 09:11:19 +0300 Subject: [PATCH] Fixed possible crash on summarizing of caption from grouped media. --- .../SourceFiles/history/view/history_view_element.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index e945fd967e..b00bddf427 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -1677,6 +1677,11 @@ void Element::validateText() { return; } } + + // Albums may show text of a different item than the parent one. + // Media::itemForText may initialize data within the object. + _textItem = _media ? _media->itemForText() : item.get(); + const auto &summary = item->summaryEntry(); const auto summaryShownWas = (_flags & Flag::SummaryShown) != 0; const auto summaryShownNow = !summary.result.empty() && summary.shown; @@ -1684,7 +1689,6 @@ void Element::validateText() { if (summaryShownNow) { _flags |= Flag::SummaryShown; if (summaryShownChanged) { - _textItem = item; setTextWithLinks(summary.result); } return; @@ -1692,8 +1696,6 @@ void Element::validateText() { _flags &= ~Flag::SummaryShown; } - // Albums may show text of a different item than the parent one. - _textItem = _media ? _media->itemForText() : item.get(); if (!_textItem) { if (!_text.isEmpty()) { setTextWithLinks({});