Fix crash when loading Steam games on flatpak

This commit is contained in:
Patrick Nicolas
2026-10-25 23:22:33 +01:00
parent 4c7d57bd6d
commit 5d69e391e4
2 changed files with 29 additions and 15 deletions
+17 -10
View File
@@ -177,21 +177,26 @@ std::optional<uint32_t> guess_steam_userid(const std::filesystem::path & root)
std::unordered_set<uint64_t> installed_appids(std::filesystem::path root)
{
wivrn::vdf::root vdf(root / "config/libraryfolders.vdf");
using values_t = std::vector<wivrn::vdf::keyvalue>;
if (vdf.key != "libraryfolders")
return {};
std::unordered_set<uint64_t> res;
for (const auto & kv: std::get<values_t>(vdf.value))
try
{
for (const auto & [appid, _]: std::get<values_t>(kv["apps"].value))
wivrn::vdf::root vdf(root / "config/libraryfolders.vdf");
using values_t = std::vector<wivrn::vdf::keyvalue>;
if (vdf.key != "libraryfolders")
return {};
for (const auto & kv: std::get<values_t>(vdf.value))
{
uint64_t val;
if (std::from_chars(appid.data.begin(), appid.data.end(), val).ec == std::errc())
res.emplace(val);
for (const auto & [appid, _]: std::get<values_t>(kv["apps"].value))
{
uint64_t val;
if (std::from_chars(appid.data.begin(), appid.data.end(), val).ec == std::errc())
res.emplace(val);
}
}
}
catch (...)
{}
return res;
}
@@ -476,6 +481,7 @@ std::vector<wivrn::steam::application> wivrn::steam::list_applications()
}
catch (std::exception & e)
{
std::cerr << "Listing Steam applications failed (user id " << *default_userid << "): " << e.what() << std::endl;
}
}
else
@@ -496,6 +502,7 @@ std::vector<wivrn::steam::application> wivrn::steam::list_applications()
}
catch (std::exception & e)
{
std::cerr << "Listing Steam applications failed (" << entry.path().filename() << "): " << e.what() << std::endl;
}
}
+12 -5
View File
@@ -145,12 +145,19 @@ wivrn::vdf::keyvalue const & wivrn::vdf::keyvalue::operator[](const char * key)
wivrn::vdf::root::root(const std::filesystem::path & file)
{
boost::iostreams::mapped_file in{file};
opaque = in;
try
{
boost::iostreams::mapped_file_source in{file};
opaque = in;
const char * pos = in.begin();
key = read_string(pos, in.end());
value = read_value(pos, in.end());
const char * pos = in.begin();
key = read_string(pos, in.end());
value = read_value(pos, in.end());
}
catch (std::exception & e)
{
throw std::runtime_error(std::format("failed to parse {}: {}", file.native(), e.what()));
}
}
void dump(const wivrn::vdf::keyvalue & kv, int depth)