From f5ac44ef2cfd1ecfff4c6d1c00f2a54f7415fd5d Mon Sep 17 00:00:00 2001 From: con Date: Wed, 2 Mar 2011 14:33:45 +0100 Subject: [PATCH] Fix crash under certain conditions when renaming tool categories. Task-number: QTCREATORBUG-3916 --- src/plugins/coreplugin/dialogs/externaltoolconfig.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp b/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp index 97afca4e15a..f2173ed762a 100644 --- a/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp +++ b/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp @@ -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 items = m_tools.take(category); m_tools.insert(string, items); if (newIndex != previousIndex)