Make action containers aware of deleted commands.

They need to remove them from their internal structure.
This commit is contained in:
con
2011-01-20 15:28:34 +01:00
parent 06acd2cc25
commit 3f0a4446f3
3 changed files with 16 additions and 1 deletions

View File

@@ -245,6 +245,7 @@ void ActionContainerPrivate::addAction(Command *command, const QString &groupId)
m_groups[groupIt-m_groups.constBegin()].items.append(command);
connect(command, SIGNAL(activeStateChanged()), this, SLOT(scheduleUpdate()));
connect(command, SIGNAL(destroyed()), this, SLOT(itemDestroyed()));
insertAction(beforeAction, command->action());
scheduleUpdate();
}
@@ -271,6 +272,17 @@ void ActionContainerPrivate::addMenu(ActionContainer *menu, const QString &group
scheduleUpdate();
}
void ActionContainerPrivate::itemDestroyed()
{
QObject *obj = sender();
QMutableListIterator<Group> it(m_groups);
while (it.hasNext()) {
Group &group = it.next();
if (group.items.removeAll(obj) > 0)
break;
}
}
int ActionContainerPrivate::id() const
{
return m_id;