Fix possible crash in message field.

Fixes #28203.
This commit is contained in:
John Preston 2024-07-30 15:25:11 +02:00
parent 4108debca0
commit 699a7bdc58

View file

@ -392,6 +392,9 @@ void InitMessageFieldHandlers(
Fn<bool()> customEmojiPaused,
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji,
const style::InputField *fieldStyle) {
const auto paused = [customEmojiPaused] {
return customEmojiPaused && customEmojiPaused();
};
field->setTagMimeProcessor(
FieldTagMimeProcessor(session, allowPremiumEmoji));
field->setCustomTextContext([=](Fn<void()> repaint) {
@ -399,10 +402,10 @@ void InitMessageFieldHandlers(
.session = session,
.customEmojiRepaint = std::move(repaint),
});
}, [customEmojiPaused] {
return On(PowerSaving::kEmojiChat) || customEmojiPaused();
}, [customEmojiPaused] {
return On(PowerSaving::kChatSpoiler) || customEmojiPaused();
}, [paused] {
return On(PowerSaving::kEmojiChat) || paused();
}, [paused] {
return On(PowerSaving::kChatSpoiler) || paused();
});
field->setInstantReplaces(Ui::InstantReplaces::Default());
field->setInstantReplacesEnabled(