From 096759435a40f94f5098db9a379d20d12704efd4 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Wed, 9 Apr 2025 01:36:52 +0100 Subject: [PATCH] Add progress bars where the launcher can be limited by IO I tested this with a USB3 external hard drive. These two places were the only ones where we're IO-bound and block the main thread, so they're the only ones that need progress bars. If trying to replicate this test, then it's important to unplug the hard drive between each repeat. Apparently Windows is excellent at disk caching these days as it takes a minute and a half to start the launcher with Total Overhaul on this drive when it's just been plugged in, but less time than the first launch after a reboot on an NVME drive once the cache has been warmed up. --- apps/launcher/datafilespage.cpp | 7 +++++++ components/config/gamesettings.cpp | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 36532a7d84..16ece6d34c 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -353,9 +354,15 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName) QIcon containsDataIcon(":/images/openmw-plugin.png"); + QProgressDialog progressBar("Adding data directories", {}, 0, directories.count(), this); + progressBar.setWindowModality(Qt::WindowModal); + progressBar.setValue(0); + std::unordered_set visitedDirectories; for (const Config::SettingValue& currentDir : directories) { + progressBar.setValue(progressBar.value() + 1); + if (!visitedDirectories.insert(currentDir.value).second) continue; diff --git a/components/config/gamesettings.cpp b/components/config/gamesettings.cpp index f318cec4a4..36373f8f35 100644 --- a/components/config/gamesettings.cpp +++ b/components/config/gamesettings.cpp @@ -1,6 +1,7 @@ #include "gamesettings.hpp" #include +#include #include #include @@ -37,8 +38,13 @@ void Config::GameSettings::validatePaths() mDataDirs.clear(); + QProgressDialog progressBar("Validating paths", {}, 0, paths.count() + 1); + progressBar.setWindowModality(Qt::WindowModal); + progressBar.setValue(0); + for (const auto& dataDir : paths) { + progressBar.setValue(progressBar.value() + 1); if (QDir(dataDir.value).exists()) { SettingValue copy = dataDir; @@ -50,6 +56,8 @@ void Config::GameSettings::validatePaths() // Do the same for data-local const QString& local = mSettings.value(QString("data-local")).value; + progressBar.setValue(progressBar.value() + 1); + if (!local.isEmpty() && QDir(local).exists()) { mDataLocal = QDir(local).canonicalPath();