File kded-fix-cmdline-parsing.patch of Package kded.openSUSE_Leap_42.1_Update

diff --git a/src/kded.cpp b/src/kded.cpp
index 6929d7d3f24d3556f1b227d5a9bfb5b02b1c295e..082d3863dcf484a6d609e2c639c49788d9576007 100644
--- a/src/kded.cpp
+++ b/src/kded.cpp
@@ -30,6 +30,7 @@
 #include <QtCore/QDir>
 #include <QtCore/QFile>
 #include <QtCore/QTimer>
+#include <QtCore/QCommandLineParser>
 #include <QApplication>
 
 #include <QDBusConnection>
@@ -672,6 +673,7 @@ static void setupAppInfo(QCoreApplication *app)
 {
     app->setApplicationName("kded5");
     app->setOrganizationDomain("kde.org");
+    app->setApplicationVersion(KDED_VERSION_STRING);
 }
 
 extern "C" Q_DECL_EXPORT int kdemain(int argc, char *argv[])
@@ -679,24 +681,27 @@ extern "C" Q_DECL_EXPORT int kdemain(int argc, char *argv[])
     //options.add("check", qi18n("Check Sycoca database only once"));
 
     // WABA: Make sure not to enable session management.
-    putenv(qstrdup("SESSION_MANAGER="));
+    qunsetenv("SESSION_MANAGER");
+
+    QApplication app(argc, argv);
+    app.setApplicationDisplayName("KDE Daemon");
+    setupAppInfo(&app);
+    app.setQuitOnLastWindowClosed(false);
+
+    QCommandLineParser parser;
+    parser.addHelpOption();
+    parser.addVersionOption();
+    parser.addOption(QCommandLineOption(QStringLiteral("check"), QStringLiteral("Check cache validity")));
+    parser.process(app);
 
     // Parse command line before checking D-Bus
-    if (argc > 1 && QByteArray(argv[1]) == "--check") {
+    if (parser.isSet(QStringLiteral("check"))) {
         // KDBusService not wanted here.
-        QCoreApplication app(argc, argv);
-        setupAppInfo(&app);
-
         KSycoca::self()->ensureCacheValid();
         runKonfUpdate();
         return 0;
     }
 
-    QApplication app(argc, argv);
-    setupAppInfo(&app);
-    app.setApplicationDisplayName("KDE Daemon");
-    app.setQuitOnLastWindowClosed(false);
-
     KDBusService service(KDBusService::Unique);
 
     KSharedConfig::Ptr config = KSharedConfig::openConfig();

openSUSE Build Service is sponsored by