Commit 60f9e919 authored by Nate Graham's avatar Nate Graham
Browse files

Fix contentRatingDescription never being empty

Various parts of the QML check to see if the string returned by this
function is empty, but it never is because as long as you have a new
enough AppStream version, the returned value will always at least have
an asterisk and a newline.

This commit fixes that problem by generating the final string in the
loop, rather than at the end in the return statement. This allows for it
to remain empty if nothing happens in the loop.
parent e9752d5f
Pipeline #225890 passed with stage
in 1 minute and 20 seconds
......@@ -143,17 +143,17 @@ QString AppStreamUtils::contentRatingDescription(const AppStream::Component &app
#if ASQ_CHECK_VERSION(0, 15, 6)
const auto ratings = appdata.contentRatings();
QStringList ret;
QString ret;
for (const auto &r : ratings) {
const auto ratingIds = r.ratingIds();
for (const auto &id : ratingIds) {
if (r.value(id) != AppStream::ContentRating::RatingValueNone) {
ret += r.description(id);
ret += QLatin1String("* ") + r.description(id) + QLatin1Char('\n');
return "* " + ret.join("\n* ");
return ret;
return {};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment