forked from qt-creator/qt-creator
Fix possible crash in environmentsmodel
Change-Id: Ib6a3450a7974dc568ba07633a38a29d598a9099f Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
committed by
Eike Ziller
parent
a1b2fc95f3
commit
0840b93ff5
@@ -211,7 +211,7 @@ bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value,
|
|||||||
const QString &newName = value.toString();
|
const QString &newName = value.toString();
|
||||||
#endif
|
#endif
|
||||||
// Does the new name exist already?
|
// Does the new name exist already?
|
||||||
if (d->m_resultEnvironment.hasKey(newName))
|
if (d->m_resultEnvironment.hasKey(newName) || newName.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Utils::EnvironmentItem newVariable(newName, oldValue);
|
Utils::EnvironmentItem newVariable(newName, oldValue);
|
||||||
@@ -227,7 +227,7 @@ bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value,
|
|||||||
const QString stringValue = value.toString();
|
const QString stringValue = value.toString();
|
||||||
if (changesPos != -1) {
|
if (changesPos != -1) {
|
||||||
// We have already changed this value
|
// We have already changed this value
|
||||||
if (stringValue == d->m_baseEnvironment.value(oldName)) {
|
if (d->m_baseEnvironment.hasKey(oldName) && stringValue == d->m_baseEnvironment.value(oldName)) {
|
||||||
// ... and now went back to the base value
|
// ... and now went back to the base value
|
||||||
d->m_items.removeAt(changesPos);
|
d->m_items.removeAt(changesPos);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user