[taskmanager] Stop parsing executables as .desktop files

Review Request #127571 - Created April 4, 2016 and submitted

Information
Rob Wu
plasma-desktop
Reviewers
plasma
When a binary is launched via an absolute path, then launcherUrl is not
empty because of [1], even though it is not a .desktop file.
Consequently, when a user right-clicks on the task item, plasmashell
attempts to parse the executable as a .desktop configuration file.
Since this file is obviously not a .desktop file, parsing it as such
will fail, and KConfig floods ~/.xsession-errors with lots of errors.
This can quickly add hundreds of megabytes per right-click...

This patch resolves the problem by not constructing a KDesktopFile if
the launcherUrl is not a .desktop file.

An alternative (and more general) way to get rid of the symptoms is to
modify KDesktopFile / KConfig to stop parsing on the first error and
write the launcherUrl to the error log (or at the very least limit the
number of displayed errors). However, it can be argued that you should
not pass a non-.desktop file to KDesktopFile.

[1] https://quickgit.kde.org/?p=kde-workspace.git&a=commit&h=3a4b9c85fc21d14838ceac04bb0a70656ee7c701

The following steps demonstrate the issue, and confirms that the patch fixes the bug.

  1. Create a simple GUI program, as follows:
// Compile: clang++ `pkg-config --cflags --libs Qt5Widgets` app.cpp -o app -g -fPIE
#include <QApplication>
#include <QLabel>

int main(int argc, char **argv) {
    QApplication app(argc, argv);
    QLabel label("Some GUI app");
    label.show();

    return app.exec();
}
  1. Run the program via an absolute path: $PWD/app.sh
  2. Right-click on the task item in the task bar (i.e. the program that you just launched).
  3. Look at ~/.xsession-errors and observe that the following lines were added.

    "KConfigIni: In file /tmp/some-qt-app/app, line 1: " Invalid entry (missing '=')
    "KConfigIni: In file /tmp/some-qt-app/app, line 2: " Invalid entry (missing '=')
    "KConfigIni: In file /tmp/some-qt-app/app, line 3: " Invalid entry (missing '=')
    "KConfigIni: In file /tmp/some-qt-app/app, line 4: " Invalid entry (missing '=')
    "KConfigIni: In file /tmp/some-qt-app/app, line 5: " Invalid entry (missing ']')
    "KConfigIni: In file /tmp/some-qt-app/app, line 6: " "Invalid escape sequence \"\\A\"."
    "KConfigIni: In file /tmp/some-qt-app/app, line 6: " "Invalid escape sequence \"\\\u0001\"."
    ... hundreds of similar lines

  1. Compile plasma-desktop with this patch and restart plasmashell.
  2. Repeat step 2 and 3.
  3. Look at ~/.xsession-errors and observe that the errors are gone.
Eike Hein
Rob Wu
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted with commit 71055e2b725fbb65e16055588f86a57c373d8b47 by Kai Uwe Broulik on behalf of Rob Wu to branch Plasma/5.6.
Loading...