File 0001-Parse-desktop-file-sections.patch of Package sddm

From 7196c7ebb423b258febed24937b6dd01b59db134 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Thu, 11 May 2017 09:56:59 +0200
Subject: [PATCH 1/3] Parse desktop file sections

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.
---
 src/common/Session.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/common/Session.cpp b/src/common/Session.cpp
index 844572c..5c2892a 100644
--- a/src/common/Session.cpp
+++ b/src/common/Session.cpp
@@ -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));
-- 
2.12.0

openSUSE Build Service is sponsored by