Fix possible crash in message context menu.
This commit is contained in:
parent
874c84ad4e
commit
7305d542ba
|
@ -2326,8 +2326,9 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
const auto item = _dragStateItem;
|
const auto item = _dragStateItem;
|
||||||
const auto itemId = item ? item->fullId() : FullMsgId();
|
const auto itemId = item ? item->fullId() : FullMsgId();
|
||||||
if (isUponSelected > 0) {
|
if (isUponSelected > 0) {
|
||||||
|
const auto selectedText = getSelectedText();
|
||||||
if (!hasCopyRestrictionForSelected()
|
if (!hasCopyRestrictionForSelected()
|
||||||
&& !getSelectedText().empty()) {
|
&& !selectedText.empty()) {
|
||||||
_menu->addAction(
|
_menu->addAction(
|
||||||
(isUponSelected > 1
|
(isUponSelected > 1
|
||||||
? tr::lng_context_copy_selected_items(tr::now)
|
? tr::lng_context_copy_selected_items(tr::now)
|
||||||
|
@ -2335,11 +2336,12 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
[=] { copySelectedText(); },
|
[=] { copySelectedText(); },
|
||||||
&st::menuIconCopy);
|
&st::menuIconCopy);
|
||||||
}
|
}
|
||||||
if (!Ui::SkipTranslate(getSelectedText().rich)) {
|
if (item && !Ui::SkipTranslate(selectedText.rich)) {
|
||||||
|
const auto peer = item->history()->peer;
|
||||||
_menu->addAction(tr::lng_context_translate_selected({}), [=] {
|
_menu->addAction(tr::lng_context_translate_selected({}), [=] {
|
||||||
_controller->show(Box(
|
_controller->show(Box(
|
||||||
Ui::TranslateBox,
|
Ui::TranslateBox,
|
||||||
item->history()->peer,
|
peer,
|
||||||
MsgId(),
|
MsgId(),
|
||||||
getSelectedText().rich,
|
getSelectedText().rich,
|
||||||
hasCopyRestrictionForSelected()));
|
hasCopyRestrictionForSelected()));
|
||||||
|
@ -2442,7 +2444,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
[=] { copySelectedText(); },
|
[=] { copySelectedText(); },
|
||||||
&st::menuIconCopy);
|
&st::menuIconCopy);
|
||||||
}
|
}
|
||||||
if (!Ui::SkipTranslate(selectedText.rich)) {
|
if (item && !Ui::SkipTranslate(selectedText.rich)) {
|
||||||
const auto peer = item->history()->peer;
|
const auto peer = item->history()->peer;
|
||||||
_menu->addAction(tr::lng_context_translate_selected({}), [=] {
|
_menu->addAction(tr::lng_context_translate_selected({}), [=] {
|
||||||
_controller->show(Box(
|
_controller->show(Box(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user