1
0
mirror of synced 2025-02-17 18:59:21 +01:00

fix: Exception when opening a null provider

This commit is contained in:
WerWolv 2024-06-29 18:49:23 +02:00
parent 5ff752c9af
commit 4b1884944d

View File

@ -173,10 +173,22 @@ namespace hex::plugin::builtin::recent {
});
std::unordered_set<RecentEntry, RecentEntry::HashFunction> uniqueProviders;
for (u32 i = 0; i < recentFilePaths.size() && uniqueProviders.size() < MaxRecentEntries; i++) {
auto &path = recentFilePaths[i];
for (const auto &path : recentFilePaths) {
if (uniqueProviders.size() >= MaxRecentEntries)
break;
try {
auto jsonData = nlohmann::json::parse(wolv::io::File(path, wolv::io::File::Mode::Read).readString());
wolv::io::File recentFile(path, wolv::io::File::Mode::Read);
if (!recentFile.isValid()) {
continue;
}
auto content = recentFile.readString();
if (content.empty()) {
continue;
}
auto jsonData = nlohmann::json::parse(content);
uniqueProviders.insert(RecentEntry {
.displayName = jsonData.at("displayName"),
.type = jsonData.at("type"),