diff --git a/ui/widgets/input_fields.cpp b/ui/widgets/input_fields.cpp index 64c7cf2..5c23eaf 100644 --- a/ui/widgets/input_fields.cpp +++ b/ui/widgets/input_fields.cpp @@ -1160,8 +1160,9 @@ void FlatInput::refreshPlaceholder(const QString &text) { } void FlatInput::contextMenuEvent(QContextMenuEvent *e) { - if (auto menu = createStandardContextMenu()) { - (new PopupMenu(this, menu))->popup(e->globalPos()); + if (const auto menu = createStandardContextMenu()) { + _contextMenu = base::make_unique_q(this, menu); + _contextMenu->popup(e->globalPos()); } } @@ -4024,7 +4025,8 @@ void MaskedInputField::setPlaceholder(rpl::producer placeholder) { void MaskedInputField::contextMenuEvent(QContextMenuEvent *e) { if (const auto menu = createStandardContextMenu()) { - (new PopupMenu(this, menu))->popup(e->globalPos()); + _contextMenu = base::make_unique_q(this, menu); + _contextMenu->popup(e->globalPos()); } } diff --git a/ui/widgets/input_fields.h b/ui/widgets/input_fields.h index 1426c07..5638c59 100644 --- a/ui/widgets/input_fields.h +++ b/ui/widgets/input_fields.h @@ -137,6 +137,9 @@ private: QTimer _touchTimer; bool _touchPress, _touchRightButton, _touchMove; QPoint _touchStart; + + base::unique_qptr _contextMenu; + }; class InputField : public RpWidget { @@ -696,6 +699,9 @@ private: bool _touchRightButton = false; bool _touchMove = false; QPoint _touchStart; + + base::unique_qptr _contextMenu; + }; class PasswordInput : public MaskedInputField {