From 699a7bdc58fc12711f331313c94d417075c550e1 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jul 2024 15:25:11 +0200 Subject: [PATCH] Fix possible crash in message field. Fixes #28203. --- Telegram/SourceFiles/chat_helpers/message_field.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index 8ee5170fb..b77fe3e3c 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -392,6 +392,9 @@ void InitMessageFieldHandlers( Fn customEmojiPaused, Fn)> allowPremiumEmoji, const style::InputField *fieldStyle) { + const auto paused = [customEmojiPaused] { + return customEmojiPaused && customEmojiPaused(); + }; field->setTagMimeProcessor( FieldTagMimeProcessor(session, allowPremiumEmoji)); field->setCustomTextContext([=](Fn 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(