Fix rich message re-layout.

Fixes #30906.
This commit is contained in:
John Preston
2026-06-30 16:40:44 +04:00
parent b72f7a1603
commit fd759d9048
2 changed files with 7 additions and 1 deletions
@@ -764,6 +764,7 @@ protected:
[[nodiscard]] int textHeightFor(int textWidth) const;
[[nodiscard]] int textRealWidth() const { return _textRealWidth; }
void validateText();
void invalidateTextSizeCache();
void validateTextSkipBlock(bool has, int width, int height);
void validateInlineKeyboard(HistoryMessageReplyMarkup *markup);
@@ -802,7 +803,6 @@ private:
}
void refreshMedia(Element *replacing);
void invalidateTextSizeCache();
void setTextWithLinks(
const TextWithEntities &text,
const std::vector<ClickHandlerPtr> &links = {});
@@ -586,6 +586,12 @@ void Message::requestRichPageRelayout(QRect articleRect) {
if (const auto rich = const_cast<Message*>(this)->richpage()) {
rich->article.invalidateLayout();
}
// The article layout was just invalidated, but textHeightFor() caches by
// _textWidth and would short-circuit when re-queried at the same (constant)
// max width, leaving the bubble sized from a stale, now-zeroed
// lastLayoutWidth(). Drop the text-size cache too so the article is really
// laid out again, the same way blockquoteExpandChanged() does for quotes.
invalidateTextSizeCache();
setPendingResize();
history()->owner().requestViewResize(this);
}