QMenu: Do not unnecessarily call QPlatformMenu::menuItemForTag()

When handling QActionEvent / ActionAdded, QActionEvent::before()
is 0 for the common 'append' case. Do not try to find a
QPlatformMenuItem for this.

Change-Id: I535b675fda6a2812b61eb8d7eec01da378ece413
Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
Reviewed-by: Albert Astals Cid <albert.astals@canonical.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Friedemann Kleint 2017-03-31 08:37:24 +02:00
parent 392294936e
commit e94e4d002e

View File

@ -3456,7 +3456,9 @@ void QMenu::actionEvent(QActionEvent *e)
QObject::connect(menuItem, SIGNAL(activated()), e->action(), SLOT(trigger()));
QObject::connect(menuItem, SIGNAL(hovered()), e->action(), SIGNAL(hovered()));
copyActionToPlatformItem(e->action(), menuItem, d->platformMenu);
QPlatformMenuItem* beforeItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->before()));
QPlatformMenuItem *beforeItem = e->before()
? d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->before()))
: nullptr;
d->platformMenu->insertMenuItem(menuItem, beforeItem);
} else if (e->type() == QEvent::ActionRemoved) {
QPlatformMenuItem *menuItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->action()));