From a116f39c63236ff215fc5056e9464506105057b2 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 28 Aug 2024 22:05:21 -0700 Subject: [PATCH] core/desktopentry: prioritize fallback keys over mismatched keys The fallback key will now be selected when there isn't a more specific key to select, instead of the first key. --- src/core/desktopentry.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/desktopentry.cpp b/src/core/desktopentry.cpp index 0fa2d8f3..3714df01 100644 --- a/src/core/desktopentry.cpp +++ b/src/core/desktopentry.cpp @@ -142,7 +142,7 @@ void DesktopEntry::parseEntry(const QString& text) { auto splitIdx = line.indexOf(u'='); if (splitIdx == -1) { - qCDebug(logDesktopEntry) << "Encountered invalid line in desktop entry (no =)" << line; + qCWarning(logDesktopEntry) << "Encountered invalid line in desktop entry (no =)" << line; continue; } @@ -159,7 +159,10 @@ void DesktopEntry::parseEntry(const QString& text) { if (entries.contains(key)) { const auto& old = entries.value(key); - if (system.matchScore(locale) > system.matchScore(old.first)) { + auto oldScore = system.matchScore(old.first); + auto newScore = system.matchScore(locale); + + if (newScore > oldScore || (oldScore == 0 && !locale.isValid())) { entries.insert(key, qMakePair(locale, value)); } } else {