forked from qt-creator/qt-creator
Make action containers aware of deleted commands.
They need to remove them from their internal structure.
This commit is contained in:
@@ -245,6 +245,7 @@ void ActionContainerPrivate::addAction(Command *command, const QString &groupId)
|
|||||||
m_groups[groupIt-m_groups.constBegin()].items.append(command);
|
m_groups[groupIt-m_groups.constBegin()].items.append(command);
|
||||||
|
|
||||||
connect(command, SIGNAL(activeStateChanged()), this, SLOT(scheduleUpdate()));
|
connect(command, SIGNAL(activeStateChanged()), this, SLOT(scheduleUpdate()));
|
||||||
|
connect(command, SIGNAL(destroyed()), this, SLOT(itemDestroyed()));
|
||||||
insertAction(beforeAction, command->action());
|
insertAction(beforeAction, command->action());
|
||||||
scheduleUpdate();
|
scheduleUpdate();
|
||||||
}
|
}
|
||||||
@@ -271,6 +272,17 @@ void ActionContainerPrivate::addMenu(ActionContainer *menu, const QString &group
|
|||||||
scheduleUpdate();
|
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
|
int ActionContainerPrivate::id() const
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ protected:
|
|||||||
private slots:
|
private slots:
|
||||||
void scheduleUpdate();
|
void scheduleUpdate();
|
||||||
void update();
|
void update();
|
||||||
|
void itemDestroyed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<Group>::const_iterator findGroup(const QString &groupId) const;
|
QList<Group>::const_iterator findGroup(const QString &groupId) const;
|
||||||
|
|||||||
@@ -247,8 +247,9 @@ ActionManagerPrivate::ActionManagerPrivate(MainWindow *mainWnd)
|
|||||||
|
|
||||||
ActionManagerPrivate::~ActionManagerPrivate()
|
ActionManagerPrivate::~ActionManagerPrivate()
|
||||||
{
|
{
|
||||||
qDeleteAll(m_idCmdMap.values());
|
// first delete containers to avoid them reacting to command deletion
|
||||||
qDeleteAll(m_idContainerMap.values());
|
qDeleteAll(m_idContainerMap.values());
|
||||||
|
qDeleteAll(m_idCmdMap.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionManagerPrivate *ActionManagerPrivate::instance()
|
ActionManagerPrivate *ActionManagerPrivate::instance()
|
||||||
@@ -382,6 +383,7 @@ void ActionManagerPrivate::unregisterAction(QAction *action, const Id &id)
|
|||||||
a->removeOverrideAction(action);
|
a->removeOverrideAction(action);
|
||||||
if (a->isEmpty()) {
|
if (a->isEmpty()) {
|
||||||
// clean up
|
// clean up
|
||||||
|
// ActionContainers listen to the commands' destroyed signals
|
||||||
m_mainWnd->removeAction(a->action());
|
m_mainWnd->removeAction(a->action());
|
||||||
delete a->action();
|
delete a->action();
|
||||||
m_idCmdMap.remove(uid);
|
m_idCmdMap.remove(uid);
|
||||||
|
|||||||
Reference in New Issue
Block a user