fakevim: fix crash in ex command mapping

Task-number: QTCREATORBUG-4084
This commit is contained in:
hjk
2011-03-17 18:15:34 +01:00
parent 5f8987d467
commit d1f62507d3

View File

@@ -307,7 +307,7 @@ public slots:
void defaultAction(); void defaultAction();
private: private:
QList<QTreeWidgetItem *> m_citems; //QList<QTreeWidgetItem *> m_citems;
FakeVimPluginPrivate *m_q; FakeVimPluginPrivate *m_q;
}; };
@@ -337,7 +337,7 @@ void FakeVimExCommandsPage::initialize()
QTreeWidgetItem *item = new QTreeWidgetItem; QTreeWidgetItem *item = new QTreeWidgetItem;
item->setData(0, CommandRole, int(c->id())); item->setData(0, CommandRole, int(c->id()));
m_citems.append(item); //m_citems.append(item);
const QString name = uidm->stringForUniqueIdentifier(c->id()); const QString name = uidm->stringForUniqueIdentifier(c->id());
const int pos = name.indexOf(QLatin1Char('.')); const int pos = name.indexOf(QLatin1Char('.'));
@@ -431,16 +431,22 @@ void FakeVimExCommandsPage::removeTargetIdentifier()
void FakeVimExCommandsPage::defaultAction() void FakeVimExCommandsPage::defaultAction()
{ {
UniqueIDManager *uidm = UniqueIDManager::instance(); UniqueIDManager *uidm = UniqueIDManager::instance();
foreach (QTreeWidgetItem *item, m_citems) { int n = commandList()->topLevelItemCount();
const int id = item->data(0, CommandRole).toInt(); for (int i = 0; i != n; ++i) {
const QString name = uidm->stringForUniqueIdentifier(id); QTreeWidgetItem *section = commandList()->topLevelItem(i);
QString regex; int m = section->childCount();
if (defaultExCommandMap().contains(name)) for (int j = 0; j != m; ++j) {
regex = defaultExCommandMap()[name].pattern(); QTreeWidgetItem *item = section->child(j);
setModified(item, false); const int id = item->data(0, CommandRole).toInt();
item->setText(2, regex); const QString name = uidm->stringForUniqueIdentifier(id);
if (item == commandList()->currentItem()) QString regex;
commandChanged(item); if (defaultExCommandMap().contains(name))
regex = defaultExCommandMap()[name].pattern();
setModified(item, false);
item->setText(2, regex);
if (item == commandList()->currentItem())
commandChanged(item);
}
} }
} }