diff options
author | flow <flowlnlnln@gmail.com> | 2022-10-18 16:51:42 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2022-10-18 16:51:42 -0300 |
commit | 3a95a3b7c18519943b6f6d13f43710f708553db3 (patch) | |
tree | 37e86729513210d19fdea77f8637337e1d93677d /launcher | |
parent | fb4cf0b75d6d72b8f35317fb5c82e668f5cdfafe (diff) | |
download | PrismLauncher-3a95a3b7c18519943b6f6d13f43710f708553db3.tar.gz PrismLauncher-3a95a3b7c18519943b6f6d13f43710f708553db3.tar.bz2 PrismLauncher-3a95a3b7c18519943b6f6d13f43710f708553db3.zip |
fix: don't take item from a possibly empty list
The list gets destroyed when we take the last object, so things explode.
:pensive:
Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher')
-rw-r--r-- | launcher/settings/INISettingsObject.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/launcher/settings/INISettingsObject.cpp b/launcher/settings/INISettingsObject.cpp index 3677e238..da962ee9 100644 --- a/launcher/settings/INISettingsObject.cpp +++ b/launcher/settings/INISettingsObject.cpp @@ -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; |