From e1624e5d2225475737469ee45d3ae1a6867a87df Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 18 Sep 2023 09:50:09 +0400 Subject: [PATCH] Fix a possible crash in translations. --- Telegram/SourceFiles/history/history_inner_widget.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 80534e1a9..0d0489dd8 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -2437,8 +2437,8 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { : QString(); if (isUponSelected > 0) { - if (!hasCopyRestrictionForSelected() - && !getSelectedText().empty()) { + const auto selectedText = getSelectedText(); + if (!hasCopyRestrictionForSelected() && !selectedText.empty()) { _menu->addAction( ((isUponSelected > 1) ? tr::lng_context_copy_selected_items(tr::now) @@ -2446,13 +2446,14 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { [=] { copySelectedText(); }, &st::menuIconCopy); } - if (!Ui::SkipTranslate(getSelectedText().rich)) { + if (!Ui::SkipTranslate(selectedText.rich)) { + const auto peer = item->history()->peer; _menu->addAction(tr::lng_context_translate_selected({}), [=] { _controller->show(Box( Ui::TranslateBox, - item->history()->peer, + peer, MsgId(), - getSelectedText().rich, + selectedText.rich, hasCopyRestrictionForSelected())); }, &st::menuIconTranslate); }