mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 15:47:11 +02:00
Fix possible crash in message translation.
This commit is contained in:
parent
a23dca080a
commit
92ff07f723
1 changed files with 7 additions and 6 deletions
|
@ -2773,7 +2773,8 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
}
|
||||
}
|
||||
if (!item->isService() && view && actionText.isEmpty()) {
|
||||
if (!hasCopyRestriction(item)
|
||||
const auto hasRestriction = hasCopyRestriction(item);
|
||||
if (!hasRestriction
|
||||
&& (view->hasVisibleText() || mediaHasTextForCopy)) {
|
||||
_menu->addAction(
|
||||
tr::lng_context_copy_text(tr::now),
|
||||
|
@ -2782,6 +2783,8 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
}
|
||||
if ((!item->translation() || !_history->translatedTo())
|
||||
&& (view->hasVisibleText() || mediaHasTextForCopy)) {
|
||||
const auto peer = item->history()->peer;
|
||||
const auto itemId = item->id;
|
||||
const auto translate = mediaHasTextForCopy
|
||||
? (HistoryView::TransribedText(item)
|
||||
.append('\n')
|
||||
|
@ -2792,12 +2795,10 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
_menu->addAction(tr::lng_context_translate(tr::now), [=] {
|
||||
_controller->show(Box(
|
||||
Ui::TranslateBox,
|
||||
item->history()->peer,
|
||||
mediaHasTextForCopy
|
||||
? MsgId()
|
||||
: item->fullId().msg,
|
||||
peer,
|
||||
mediaHasTextForCopy ? MsgId() : itemId,
|
||||
translate,
|
||||
hasCopyRestriction(item)));
|
||||
hasRestriction));
|
||||
}, &st::menuIconTranslate);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue