Commit 40623d00 authored by con's avatar con
Browse files

Handle action containers with custom QActions more gracefully.

Related to QTCREATORBUG-1764.
parent 66e01e88
...@@ -390,8 +390,10 @@ bool MenuActionContainer::updateInternal() ...@@ -390,8 +390,10 @@ bool MenuActionContainer::updateInternal()
return true; return true;
bool hasitems = false; bool hasitems = false;
QList<QAction *> actions = m_menu->actions();
foreach (ActionContainer *container, subContainers()) { foreach (ActionContainer *container, subContainers()) {
actions.removeAll(container->menu()->menuAction());
if (container == this) { if (container == this) {
qWarning() << Q_FUNC_INFO << "container" << (this->menu() ? this->menu()->title() : "") << "contains itself as subcontainer"; qWarning() << Q_FUNC_INFO << "container" << (this->menu() ? this->menu()->title() : "") << "contains itself as subcontainer";
continue; continue;
...@@ -403,12 +405,22 @@ bool MenuActionContainer::updateInternal() ...@@ -403,12 +405,22 @@ bool MenuActionContainer::updateInternal()
} }
if (!hasitems) { if (!hasitems) {
foreach (Command *command, commands()) { foreach (Command *command, commands()) {
actions.removeAll(command->action());
if (command->isActive()) { if (command->isActive()) {
hasitems = true; hasitems = true;
break; break;
} }
} }
} }
if (!hasitems) {
// look if there were actions added that we don't control and check if they are enabled
foreach (const QAction *action, actions) {
if (!action->isSeparator() && action->isEnabled()) {
hasitems = true;
break;
}
}
}
if (hasEmptyAction(EA_Hide)) if (hasEmptyAction(EA_Hide))
m_menu->setVisible(hasitems); m_menu->setVisible(hasitems);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment