Skip to content

Commit

Permalink
Parse desktop file sections
Browse files Browse the repository at this point in the history
Some desktop files have multiple sections, but for now we're only
interested in [Desktop Entry]. Without this patch, every entry was seen
as part of the [Desktop Entry] session, resulting in values getting
overwritten.
  • Loading branch information
Vogtinator committed May 11, 2017
1 parent c254ede commit 7196c7e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/common/Session.cpp
Expand Up @@ -138,10 +138,22 @@ namespace SDDM {
if (!file.open(QIODevice::ReadOnly))
return;

QString current_section;

QTextStream in(&file);
while (!in.atEnd()) {
QString line = in.readLine();

if (line.startsWith(QLatin1String("["))) {
// The section name ends before the last ] before the start of a comment
int end = line.lastIndexOf(QLatin1Char(']'), line.indexOf(QLatin1Char('#')));
if (end != -1)
current_section = line.mid(1, end - 1);
}

if (current_section != QLatin1String("Desktop Entry"))
continue; // We are only interested in the "Desktop Entry" section

if (line.startsWith(QLatin1String("Name="))) {
if (type == WaylandSession)
m_displayName = QObject::tr("%1 (Wayland)").arg(line.mid(5));
Expand Down

0 comments on commit 7196c7e

Please sign in to comment.