Fix crash in recent actions with spoilers.

This commit is contained in:
John Preston 2022-09-25 18:17:27 +04:00
parent 0e6c899cee
commit 6cb01998cc
4 changed files with 48 additions and 17 deletions

View File

@ -247,7 +247,17 @@ void Game::draw(Painter &p, const PaintContext &context) const {
endskip = _parent->skipBlockWidth();
}
_parent->prepareCustomEmojiPaint(p, context, _description);
_description.drawLeftElided(p, padding.left(), tshift, paintw, width(), _descriptionLines, style::al_left, 0, -1, endskip, false, toDescriptionSelection(context.selection));
_description.draw(p, {
.position = { padding.left(), tshift },
.outerWidth = width(),
.availableWidth = paintw,
.spoiler = Ui::Text::DefaultSpoilerCache(),
.now = context.now,
.paused = context.paused,
.selection = toDescriptionSelection(context.selection),
.elisionLines = _descriptionLines,
.elisionRemoveFromEnd = endskip,
});
tshift += _descriptionLines * lineHeight;
}
if (_attach) {

View File

@ -228,7 +228,16 @@ void Invoice::draw(Painter &p, const PaintContext &context) const {
}
if (_descriptionHeight) {
p.setPen(stm->historyTextFg);
_description.drawLeft(p, padding.left(), tshift, paintw, width(), style::al_left, 0, -1, toDescriptionSelection(context.selection));
_parent->prepareCustomEmojiPaint(p, context, _description);
_description.draw(p, {
.position = { padding.left(), tshift },
.outerWidth = width(),
.availableWidth = paintw,
.spoiler = Ui::Text::DefaultSpoilerCache(),
.now = context.now,
.paused = context.paused,
.selection = toDescriptionSelection(context.selection),
});
tshift += _descriptionHeight;
}
if (_attach) {
@ -353,6 +362,17 @@ void Invoice::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed)
}
}
bool Invoice::hasHeavyPart() const {
return _attach ? _attach->hasHeavyPart() : false;
}
void Invoice::unloadHeavyPart() {
if (_attach) {
_attach->unloadHeavyPart();
}
_description.unloadPersistentAnimation();
}
TextForMimeData Invoice::selectedText(TextSelection selection) const {
auto titleResult = _title.toTextForMimeData(selection);
auto descriptionResult = _description.toTextForMimeData(

View File

@ -70,14 +70,8 @@ public:
return _attach.get();
}
bool hasHeavyPart() const override {
return _attach ? _attach->hasHeavyPart() : false;
}
void unloadHeavyPart() override {
if (_attach) {
_attach->unloadHeavyPart();
}
}
bool hasHeavyPart() const override;
void unloadHeavyPart() override;
private:
QSize countOptimalSize() override;

View File

@ -568,13 +568,20 @@ void WebPage::draw(Painter &p, const PaintContext &context) const {
endskip = _parent->skipBlockWidth();
}
_parent->prepareCustomEmojiPaint(p, context, _description);
if (_descriptionLines > 0) {
_description.drawLeftElided(p, padding.left(), tshift, paintw, width(), _descriptionLines, style::al_left, 0, -1, endskip, false, toDescriptionSelection(context.selection));
tshift += _descriptionLines * lineHeight;
} else {
_description.drawLeft(p, padding.left(), tshift, paintw, width(), style::al_left, 0, -1, toDescriptionSelection(context.selection));
tshift += _description.countHeight(paintw);
}
_description.draw(p, {
.position = { padding.left(), tshift },
.outerWidth = width(),
.availableWidth = paintw,
.spoiler = Ui::Text::DefaultSpoilerCache(),
.now = context.now,
.paused = context.paused,
.selection = toDescriptionSelection(context.selection),
.elisionLines = std::max(_descriptionLines, 0),
.elisionRemoveFromEnd = (_descriptionLines > 0) ? endskip : 0,
});
tshift += (_descriptionLines > 0)
? (_descriptionLines * lineHeight)
: _description.countHeight(paintw);
}
if (_attach) {
auto attachAtTop = !_siteNameLines && !_titleLines && !_descriptionLines;