mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 10:11:41 -05:00
Fix crash: transfer QMenu ownership to PopupMenu. Not tested.
This commit is contained in:
parent
1cfe9d0ff5
commit
c8a379e85e
3 changed files with 13 additions and 10 deletions
|
@ -243,7 +243,7 @@ void FlatInput::updatePlaceholderText() {
|
|||
}
|
||||
|
||||
void FlatInput::contextMenuEvent(QContextMenuEvent *e) {
|
||||
if (QMenu *menu = createStandardContextMenu()) {
|
||||
if (auto menu = createStandardContextMenu()) {
|
||||
(new PopupMenu(menu))->popup(e->globalPos());
|
||||
}
|
||||
}
|
||||
|
@ -1281,7 +1281,7 @@ void InputArea::Inner::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
|
||||
void InputArea::Inner::contextMenuEvent(QContextMenuEvent *e) {
|
||||
if (QMenu *menu = createStandardContextMenu()) {
|
||||
if (auto menu = createStandardContextMenu()) {
|
||||
(new PopupMenu(menu))->popup(e->globalPos());
|
||||
}
|
||||
}
|
||||
|
@ -2028,7 +2028,7 @@ void InputField::Inner::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
|
||||
void InputField::Inner::contextMenuEvent(QContextMenuEvent *e) {
|
||||
if (QMenu *menu = createStandardContextMenu()) {
|
||||
if (auto menu = createStandardContextMenu()) {
|
||||
(new PopupMenu(menu))->popup(e->globalPos());
|
||||
}
|
||||
}
|
||||
|
@ -2236,7 +2236,7 @@ void MaskedInputField::updatePlaceholderText() {
|
|||
}
|
||||
|
||||
void MaskedInputField::contextMenuEvent(QContextMenuEvent *e) {
|
||||
if (QMenu *menu = createStandardContextMenu()) {
|
||||
if (auto menu = createStandardContextMenu()) {
|
||||
(new PopupMenu(menu))->popup(e->globalPos());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1420,7 +1420,7 @@ void FlatTextarea::dropEvent(QDropEvent *e) {
|
|||
}
|
||||
|
||||
void FlatTextarea::contextMenuEvent(QContextMenuEvent *e) {
|
||||
if (QMenu *menu = createStandardContextMenu()) {
|
||||
if (auto menu = createStandardContextMenu()) {
|
||||
(new PopupMenu(menu))->popup(e->globalPos());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ PopupMenu::PopupMenu(const style::PopupMenu &st) : TWidget(nullptr)
|
|||
init();
|
||||
}
|
||||
|
||||
PopupMenu::PopupMenu(QMenu *menu, const style::PopupMenu &st) : TWidget(0)
|
||||
PopupMenu::PopupMenu(QMenu *menu, const style::PopupMenu &st) : TWidget(nullptr)
|
||||
, _st(st)
|
||||
, _menu(menu)
|
||||
, _itemHeight(_st.itemPadding.top() + _st.itemFont->height + _st.itemPadding.bottom())
|
||||
|
@ -43,6 +43,9 @@ PopupMenu::PopupMenu(QMenu *menu, const style::PopupMenu &st) : TWidget(0)
|
|||
, _shadow(_st.shadow)
|
||||
, a_opacity(1)
|
||||
, _a_hide(animation(this, &PopupMenu::step_hide)) {
|
||||
_menu->setParent(this);
|
||||
_menu->hide();
|
||||
|
||||
init();
|
||||
for (auto action : menu->actions()) {
|
||||
addAction(action);
|
||||
|
@ -72,11 +75,11 @@ QAction *PopupMenu::addAction(const QString &text, const QObject *receiver, cons
|
|||
QAction *PopupMenu::addAction(QAction *a) {
|
||||
connect(a, SIGNAL(changed()), this, SLOT(actionChanged()));
|
||||
_actions.push_back(a);
|
||||
if (a->menu()) {
|
||||
_menus.push_back(new PopupMenu(a->menu()));
|
||||
if (auto submenu = a->menu()) {
|
||||
_menus.push_back(new PopupMenu(submenu));
|
||||
_menus.back()->deleteOnHide(false);
|
||||
} else {
|
||||
_menus.push_back(0);
|
||||
_menus.push_back(nullptr);
|
||||
}
|
||||
_texts.push_back(QString());
|
||||
_shortcutTexts.push_back(QString());
|
||||
|
@ -503,7 +506,7 @@ void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, PressSource source)
|
|||
|
||||
PopupMenu::~PopupMenu() {
|
||||
clearActions(true);
|
||||
delete _menu;
|
||||
|
||||
#if defined Q_OS_LINUX32 || defined Q_OS_LINUX64
|
||||
if (auto w = App::wnd()) {
|
||||
w->onReActivate();
|
||||
|
|
Loading…
Add table
Reference in a new issue