fix: don't take item from a possibly empty list

The list gets destroyed when we take the last object, so things explode.
😔

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-10-18 16:51:42 -03:00
parent fb4cf0b75d
commit 3a95a3b7c1
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469

View File

@ -23,14 +23,16 @@ INISettingsObject::INISettingsObject(QStringList paths, QObject *parent)
: SettingsObject(parent)
{
auto first_path = paths.constFirst();
auto path = paths.takeFirst();
while (!QFile::exists(path))
path = paths.takeFirst();
for (auto path : paths) {
if (!QFile::exists(path))
continue;
if (path != first_path && QFile::exists(path)) {
// Copy the fallback to the preferred path.
QFile::copy(path, first_path);
qDebug() << "Copied settings from" << path << "to" << first_path;
if (path != first_path && QFile::exists(path)) {
// Copy the fallback to the preferred path.
QFile::copy(path, first_path);
qDebug() << "Copied settings from" << path << "to" << first_path;
break;
}
}
m_filePath = first_path;