Search for the ServiceTypes key in the desktop file before
parsing it "for real", because how it's parsed depends from
the service type definition, so if the servicetype is defined
at the bottom of the file or after keys dependent from the type,
those keys would be parsed incorrectly
Details
- Reviewers
davidedmundson apol dfaure - Group Reviewers
Plasma - Commits
- R244:2a9b56e93407: parse the desktop file 2 times
things using plugins like plasmashell still start correctly,
dropping on the desktop a text file now proposes to create a notes widget.
The notes widget has ServiceTypes defined *after* X-Plasma-DropMimetypes
which is a stringlist, that would be misinterpreted as a string
otherwise
Diff Detail
- Repository
- R244 KCoreAddons
- Branch
- phab/prse2servicetypes
- Lint
No Linters Available - Unit
No Unit Test Coverage
src/lib/plugin/desktopfileparser.cpp | ||
---|---|---|
237 | maybe instead a bool it could have error codes to more easily assure the behavior is 100% the same as before |
src/lib/plugin/desktopfileparser.cpp | ||
---|---|---|
537 | We don't need to close readUntilDesktopEntryGroup() |
Also you can remove the lines
} else if (key == QByteArrayLiteral("X-KDE-ServiceTypes") || key == QByteArrayLiteral("ServiceTypes")) { const auto services = deserializeList(value);
- for(const auto &service : services) {
- // some .desktop files still use the legacy ServiceTypes= key
- QString fileName = service.toLower().replace(QLatin1Char('/'), QLatin1Char('-'))+QStringLiteral(".desktop");
- serviceTypes.addFile(fileName);
- }
from inside DesktopFileParser::convertToJson as we'll hae already done that
(I had written https://paste.kde.org/pipfub7bu last night, but wanted to split that tokenisation out that you've done)
How about adding a test?
Other than that, the patch looks good.
It's horrible that we need to do so, but I guess it's the price of backwards compatibility. There's the possibility of doing the processing in two steps (desktop to pairs, pairs to json), but we agreed that this code shouldn't be optimized anyway (as it's transitional and what we support is json).