1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-01 00:36:46 +00:00

Avoid reverse iteration on QHash

This commit is contained in:
Andrei Kortunov 2020-06-23 10:14:19 +04:00
parent 0bb9322a69
commit 19e95afc42

View file

@ -127,7 +127,12 @@ bool Wizard::IniSettings::writeFile(const QString &path, QTextStream &stream)
QString key(fullKey.at(1)); QString key(fullKey.at(1));
int index = buffer.lastIndexOf(section); int index = buffer.lastIndexOf(section);
if (index != -1) { if (index == -1) {
// Add the section to the end of the file, because it's not found
buffer.append(QString("\n%1\n").arg(section));
index = buffer.lastIndexOf(section);
}
// Look for the next section // Look for the next section
index = buffer.indexOf(QLatin1Char('['), index + 1); index = buffer.indexOf(QLatin1Char('['), index + 1);
@ -141,12 +146,6 @@ bool Wizard::IniSettings::writeFile(const QString &path, QTextStream &stream)
buffer.insert(index - 1, QString("\n%1=%2").arg(key, i.value().toString())); buffer.insert(index - 1, QString("\n%1=%2").arg(key, i.value().toString()));
mSettings.remove(i.key()); mSettings.remove(i.key());
} }
} else {
// Add the section to the end of the file, because it's not found
buffer.append(QString("\n%1\n").arg(section));
i.previous();
}
} }
// Now we reopen the file, this time we write // Now we reopen the file, this time we write