Use base::unique_qptr for PopupMenu-s.

This commit is contained in:
John Preston 2021-12-09 21:55:19 +04:00
parent a6eae0aa27
commit 7efa1f9b2b
2 changed files with 11 additions and 3 deletions

View file

@ -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<PopupMenu>(this, menu);
_contextMenu->popup(e->globalPos());
}
}
@ -4024,7 +4025,8 @@ void MaskedInputField::setPlaceholder(rpl::producer<QString> placeholder) {
void MaskedInputField::contextMenuEvent(QContextMenuEvent *e) {
if (const auto menu = createStandardContextMenu()) {
(new PopupMenu(this, menu))->popup(e->globalPos());
_contextMenu = base::make_unique_q<PopupMenu>(this, menu);
_contextMenu->popup(e->globalPos());
}
}

View file

@ -137,6 +137,9 @@ private:
QTimer _touchTimer;
bool _touchPress, _touchRightButton, _touchMove;
QPoint _touchStart;
base::unique_qptr<PopupMenu> _contextMenu;
};
class InputField : public RpWidget {
@ -696,6 +699,9 @@ private:
bool _touchRightButton = false;
bool _touchMove = false;
QPoint _touchStart;
base::unique_qptr<PopupMenu> _contextMenu;
};
class PasswordInput : public MaskedInputField {