diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-08-17 02:41:57 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-11-03 11:39:07 -0500 |
| commit | ee53312652af10fbddb5d1d16db6212bca2b9665 (patch) | |
| tree | 86db22dc6219f25c3266b70223a0dd55b0c328cb /src/instancemanagerdialog.cpp | |
| parent | a9772873d69b875f5617c0121c73a271d432a29c (diff) | |
moved naturalCompare() to uibase
don't try to delete paths that don't exist
natsort for instance names and games
Diffstat (limited to 'src/instancemanagerdialog.cpp')
| -rw-r--r-- | src/instancemanagerdialog.cpp | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/instancemanagerdialog.cpp b/src/instancemanagerdialog.cpp index 37bdea7b..3b9dd344 100644 --- a/src/instancemanagerdialog.cpp +++ b/src/instancemanagerdialog.cpp @@ -191,13 +191,17 @@ public: // a portable instance has its location in the installation directory, // don't delete that if (!isPortable()) { - roots.push_back({loc, true}); + if (QDir(loc).exists()) { + roots.push_back({loc, true}); + } } // the base directory is the location directory by default, don't add it // if it's the same if (canonicalDir(base) != canonicalDir(loc)) { - roots.push_back({base, false}); + if (QDir(base).exists()) { + roots.push_back({base, false}); + } } @@ -234,8 +238,11 @@ public: } if (!inRoots) { - // not in roots, this is a path that was changed by the user - cleanDirs.push_back({prettyDir(f.path), f.mandatoryDelete}); + // not in roots, this is a path that was changed by the user; make + // sure it exists + if (QDir(f.path).exists()) { + cleanDirs.push_back({prettyDir(f.path), f.mandatoryDelete}); + } } } @@ -264,8 +271,11 @@ public: } if (!inRoots) { - // not in roots, this is a path that was changed by the user - cleanFiles.push_back({prettyFile(f.path), f.mandatoryDelete}); + // not in roots, this is a path that was changed by the user; make + // sure it exists + if (QFileInfo(f.path).exists()) { + cleanFiles.push_back({prettyFile(f.path), f.mandatoryDelete}); + } } } @@ -338,14 +348,20 @@ void InstanceManagerDialog::updateInstances() m_instances.clear(); - if (m.portableInstanceExists()) { - m_instances.push_back(std::make_unique<InstanceInfo>( - m.portablePath(), true)); - } - for (auto&& d : m.instancePaths()) { m_instances.push_back(std::make_unique<InstanceInfo>(d, false)); } + + // sort first, prepend portable after so it's always on top + std::sort(m_instances.begin(), m_instances.end(), [](auto&& a, auto&& b) { + return (MOBase::naturalCompare(a->name(), b->name()) < 0); + }); + + if (m.portableInstanceExists()) { + m_instances.insert( + m_instances.begin(), + std::make_unique<InstanceInfo>(m.portablePath(), true)); + } } void InstanceManagerDialog::updateList() |
