Commit f5d68d9c authored by dt's avatar dt
Browse files

EnvironmentModel: Fix crash on clicking add twice

Task-Nr: QTCREATORBUG-3336
parent cc75d11a
...@@ -291,14 +291,13 @@ QModelIndex EnvironmentModel::addVariable() ...@@ -291,14 +291,13 @@ QModelIndex EnvironmentModel::addVariable()
QModelIndex EnvironmentModel::addVariable(const Utils::EnvironmentItem &item) QModelIndex EnvironmentModel::addVariable(const Utils::EnvironmentItem &item)
{ {
int insertPos = findInResultInsertPosition(item.name);
// Return existing index if the name is already in the result set: // Return existing index if the name is already in the result set:
if (insertPos < m_resultEnvironment.size() int pos = findInResult(item.name);
&& m_resultEnvironment.key(m_resultEnvironment.constBegin() + insertPos) == item.name) { if (pos < m_resultEnvironment.size())
return index(insertPos, 0, QModelIndex()); return index(pos, 0, QModelIndex());
}
int insertPos = findInResultInsertPosition(item.name);
int changePos = findInChanges(item.name); int changePos = findInChanges(item.name);
if (m_baseEnvironment.hasKey(item.name)) { if (m_baseEnvironment.hasKey(item.name)) {
// We previously unset this! // We previously unset this!
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment