mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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 (!item->isService() && view && actionText.isEmpty()) {
|
||||||
if (!hasCopyRestriction(item)
|
const auto hasRestriction = hasCopyRestriction(item);
|
||||||
|
if (!hasRestriction
|
||||||
&& (view->hasVisibleText() || mediaHasTextForCopy)) {
|
&& (view->hasVisibleText() || mediaHasTextForCopy)) {
|
||||||
_menu->addAction(
|
_menu->addAction(
|
||||||
tr::lng_context_copy_text(tr::now),
|
tr::lng_context_copy_text(tr::now),
|
||||||
|
@ -2782,6 +2783,8 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
}
|
}
|
||||||
if ((!item->translation() || !_history->translatedTo())
|
if ((!item->translation() || !_history->translatedTo())
|
||||||
&& (view->hasVisibleText() || mediaHasTextForCopy)) {
|
&& (view->hasVisibleText() || mediaHasTextForCopy)) {
|
||||||
|
const auto peer = item->history()->peer;
|
||||||
|
const auto itemId = item->id;
|
||||||
const auto translate = mediaHasTextForCopy
|
const auto translate = mediaHasTextForCopy
|
||||||
? (HistoryView::TransribedText(item)
|
? (HistoryView::TransribedText(item)
|
||||||
.append('\n')
|
.append('\n')
|
||||||
|
@ -2792,12 +2795,10 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
_menu->addAction(tr::lng_context_translate(tr::now), [=] {
|
_menu->addAction(tr::lng_context_translate(tr::now), [=] {
|
||||||
_controller->show(Box(
|
_controller->show(Box(
|
||||||
Ui::TranslateBox,
|
Ui::TranslateBox,
|
||||||
item->history()->peer,
|
peer,
|
||||||
mediaHasTextForCopy
|
mediaHasTextForCopy ? MsgId() : itemId,
|
||||||
? MsgId()
|
|
||||||
: item->fullId().msg,
|
|
||||||
translate,
|
translate,
|
||||||
hasCopyRestriction(item)));
|
hasRestriction));
|
||||||
}, &st::menuIconTranslate);
|
}, &st::menuIconTranslate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue