diff --git a/autotests/kmimeassociationstest.cpp b/autotests/kmimeassociationstest.cpp --- a/autotests/kmimeassociationstest.cpp +++ b/autotests/kmimeassociationstest.cpp @@ -121,7 +121,8 @@ { setupXdgDirs(); QStandardPaths::setTestModeEnabled(true); - qputenv("XDG_CURRENT_DESKTOP", "KDE"); + // The Plasma bit makes no sense, but this is just to test that this is treated as a colon-separated list + qputenv("XDG_CURRENT_DESKTOP", "KDE:Plasma"); m_localConfig = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/'); QDir(m_localConfig).removeRecursively(); diff --git a/src/services/kservice.cpp b/src/services/kservice.cpp --- a/src/services/kservice.cpp +++ b/src/services/kservice.cpp @@ -655,19 +655,21 @@ { Q_D(const KService); - QStringList currentDesktops(QString::fromLatin1(qgetenv("XDG_CURRENT_DESKTOP"))); + const QString envVar = QString::fromLatin1(qgetenv("XDG_CURRENT_DESKTOP")); + QVector currentDesktops(envVar.splitRef(QLatin1Char(':'), Qt::SkipEmptyParts)); + const QString kde = QStringLiteral("KDE"); if (currentDesktops.isEmpty()) { // This could be an old display manager, or e.g. a failsafe session with no desktop name // In doubt, let's say we show KDE stuff. - currentDesktops << QStringLiteral("KDE"); + currentDesktops.append(&kde); } // This algorithm is described in the desktop entry spec QMap::ConstIterator it = d->m_mapProps.find(QStringLiteral("OnlyShowIn")); if ((it != d->m_mapProps.end()) && (it->isValid())) { const QStringList aList = it->toString().split(QLatin1Char(';')); - for (const QString &desktop : qAsConst(currentDesktops)) { + for (const QStringRef &desktop : qAsConst(currentDesktops)) { if (aList.contains(desktop)) { return true; } @@ -678,7 +680,7 @@ it = d->m_mapProps.find(QStringLiteral("NotShowIn")); if ((it != d->m_mapProps.end()) && (it->isValid())) { const QStringList aList = it->toString().split(QLatin1Char(';')); - for (const QString &desktop : qAsConst(currentDesktops)) { + for (const QStringRef &desktop : qAsConst(currentDesktops)) { if (aList.contains(desktop)) { return false; }