Do not use toobar menu as fallback context menu

This is a consequence of e91572a0, although it is not clear why. The
contextMenuEvent code of the workarea should not delegate context
menu when it cannot honor it.

Also fix a small memory leak.

Fixes bug #10616.
This commit is contained in:
Jean-Marc Lasgouttes 2017-07-05 12:28:26 +02:00
parent f0856a4ad0
commit ab81c23656
2 changed files with 3 additions and 4 deletions

View File

@ -3440,8 +3440,7 @@ bool GuiView::goToFileRow(string const & argument)
void GuiView::toolBarPopup(const QPoint & /*pos*/)
{
QMenu * menu = new QMenu;
menu = guiApp->menus().menu(toqstr("context-toolbars"), * this);
QMenu * menu = guiApp->menus().menu(toqstr("context-toolbars"), * this);
menu->exec(QCursor::pos());
}

View File

@ -777,7 +777,7 @@ void GuiWorkArea::contextMenuEvent(QContextMenuEvent * e)
}
if (name.empty()) {
QAbstractScrollArea::contextMenuEvent(e);
e->accept();
return;
}
// always show mnemonics when the keyboard is used to show the context menu
@ -785,7 +785,7 @@ void GuiWorkArea::contextMenuEvent(QContextMenuEvent * e)
bool const keyboard = (e->reason() == QContextMenuEvent::Keyboard);
QMenu * menu = guiApp->menus().menu(toqstr(name), *d->lyx_view_, keyboard);
if (!menu) {
QAbstractScrollArea::contextMenuEvent(e);
e->accept();
return;
}
// Position the menu to the right.