diff --git a/es-app/src/CollectionSystemsManager.cpp b/es-app/src/CollectionSystemsManager.cpp index 154c6e038..47bb420fd 100644 --- a/es-app/src/CollectionSystemsManager.cpp +++ b/es-app/src/CollectionSystemsManager.cpp @@ -1300,6 +1300,8 @@ void CollectionSystemsManager::removeCollectionsFromDisplayedSystems() // Remove all custom collections in bundle. // This should not delete the objects from memory! + if (mCustomCollectionsBundle == nullptr) + return; FileData* customRoot {mCustomCollectionsBundle->getRootFolder()}; std::vector mChildren {customRoot->getChildren()}; for (auto it = mChildren.cbegin(); it != mChildren.cend(); ++it) { diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index b092cd5f8..a13fb144b 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -460,9 +460,34 @@ bool SystemData::loadConfig() const std::vector& configPaths {getConfigPath(true)}; const std::string& rompath {FileData::getROMDirectory()}; - bool onlyProcessCustomFile {false}; + const bool splashScreen {Settings::getInstance()->getBool("SplashScreen")}; + float systemCount {0.0f}; + float loadedSystems {0.0f}; + + // This is only done to get the total system count, for calculating the progress bar position. + for (auto& configPath : configPaths) { + pugi::xml_document doc; +#if defined(_WIN64) + const pugi::xml_parse_result& res { + doc.load_file(Utils::String::stringToWideString(configPath).c_str())}; +#else + const pugi::xml_parse_result& res {doc.load_file(configPath.c_str())}; +#endif + if (!res) + break; + const pugi::xml_node& systemList {doc.child("systemList")}; + if (!systemList) + continue; + for (pugi::xml_node system {systemList.child("system")}; system; + system = system.next_sibling("system")) { + ++systemCount; + } + if (doc.child("loadExclusive")) + break; + } + for (auto& configPath : configPaths) { // If the loadExclusive tag is present in the custom es_systems.xml file, then skip // processing of the bundled configuration file. @@ -510,17 +535,9 @@ bool SystemData::loadConfig() return true; } - const bool splashScreen {Settings::getInstance()->getBool("SplashScreen")}; - float systemCount {0.0f}; - float loadedSystems {0.0f}; uint64_t lastTime {0}; uint64_t accumulator {0}; - for (pugi::xml_node system {systemList.child("system")}; system; - system = system.next_sibling("system")) { - ++systemCount; - } - for (pugi::xml_node system {systemList.child("system")}; system; system = system.next_sibling("system")) { std::string name; @@ -749,10 +766,11 @@ bool SystemData::loadConfig() sSystemVector.emplace_back(newSys); } } - if (splashScreen) - Window::getInstance()->renderSplashScreen(Window::SplashScreenState::SCANNING, 0.5f); } + if (splashScreen) + Window::getInstance()->renderSplashScreen(Window::SplashScreenState::SCANNING, 0.5f); + // Sort systems by sortName, which will normally be the same as the full name. std::sort(std::begin(sSystemVector), std::end(sSystemVector), [](SystemData* a, SystemData* b) { return Utils::String::toUpper(a->getSortName()) < Utils::String::toUpper(b->getSortName()); @@ -818,7 +836,7 @@ std::vector SystemData::getConfigPath(bool legacyWarning) } } - std::string path = customSystemsDirectory + "/es_systems.xml"; + std::string path {customSystemsDirectory + "/es_systems.xml"}; if (Utils::FileSystem::exists(path)) { LOG(LogInfo) << "Found custom systems configuration file";