Fix crash under certain conditions when renaming tool categories.

Task-number: QTCREATORBUG-3916
This commit is contained in:
con
2011-03-02 14:33:45 +01:00
parent a87a8e71f9
commit f5ac44ef2c

View File

@@ -252,8 +252,11 @@ bool ExternalToolModel::setData(const QModelIndex &modelIndex, const QVariant &v
categories.append(string);
qSort(categories);
int newIndex = categories.indexOf(string);
if (newIndex != previousIndex)
beginMoveRows(QModelIndex(), previousIndex, previousIndex, QModelIndex(), newIndex);
if (newIndex != previousIndex) {
// we have same parent so we have to do special stuff for beginMoveRows...
int beginMoveRowsSpecialIndex = (previousIndex < newIndex ? newIndex + 1 : newIndex);
beginMoveRows(QModelIndex(), previousIndex, previousIndex, QModelIndex(), beginMoveRowsSpecialIndex);
}
QList<ExternalTool *> items = m_tools.take(category);
m_tools.insert(string, items);
if (newIndex != previousIndex)