From a86829ae62b4338be716b3d75642321e631dcdec Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Sat, 4 Feb 2023 22:14:16 +0100 Subject: [PATCH] Leave duplicate symlinks out of the SessionModel Used for autologin (default.desktop) and backwards-compat. --- src/greeter/SessionModel.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/greeter/SessionModel.cpp b/src/greeter/SessionModel.cpp index 3a89d42..9eaab10 100644 --- a/src/greeter/SessionModel.cpp +++ b/src/greeter/SessionModel.cpp @@ -136,6 +136,15 @@ namespace SDDM { sessions.removeDuplicates(); for (auto& session : qAsConst(sessions)) { Session *si = new Session(type, session); + + // Skip symlinks that point to the same directory, + // they will be visited under the real name + QFileInfo fi_link(si->fileName()); + if (fi_link.isSymLink() && fi_link.canonicalPath() == si->directory().path()) { + delete si; + continue; + } + bool execAllowed = true; QFileInfo fi(si->tryExec()); if (fi.isAbsolute()) { @@ -164,8 +173,10 @@ namespace SDDM { } } // find out index of the last session + const QString canonicalLastSession = QFileInfo(stateConfig.Last.Session.get()).canonicalFilePath(); for (int i = 0; i < d->sessions.size(); ++i) { - if (d->sessions.at(i)->fileName() == stateConfig.Last.Session.get()) { + const QString canonicalSession = QFileInfo(d->sessions.at(i)->fileName()).canonicalFilePath(); + if (canonicalSession == canonicalLastSession) { d->lastIndex = i; break; } -- 2.39.1