D29738: Fix service file specifying 'Run in terminal' giving an error code 100

Jonathan Marten noreply at phabricator.kde.org
Thu May 14 10:40:45 BST 2020


marten created this revision.
marten added reviewers: Frameworks, dfaure.
Herald added a project: Frameworks.
Herald added a subscriber: kde-frameworks-devel.
marten requested review of this revision.

REVISION SUMMARY
  https://bugs.kde.org/show_bug.cgi?id=421374 describes how a service file specified to run in a terminal gives an error saying that it cannot find 'konsole' or the user's configured terminal program.
  
  The problem is that KIO::DesktopExecParser::resultingArguments(), if service.terminal() is true, prepends the terminal application to the command line.  If this is a relative path, as it is most likely to be (and will be in the default 'konsole' case), the "realExecutable" check in KProcessRunner::KProcessRunner() is triggered and the job aborts with an error message.
  
  This change expands the specified terminal executable into a full path in KIO::DesktopExecParser::resultingArguments(), and returns an error immediately if it cannot be found.  This is then prepended to the command line.  When KProcessRunner::KProcessRunner() checks the realExecutable (the first word of the command line) it will be an absolute path and the check will not fail.
  
  The order of the code blocks in KProcessRunner::KProcessRunner() is adjusted so that execParser.resultingArguments() is checked for being empty (an error return) before the first word of the command is accessed.  This means that the "realExecutable = execParser.resultingArguments().at(0)" test will not assert if resultingArguments() is an empty list.

TEST PLAN
  Built kio with this change, tested with the sample desktop file at https://bugs.kde.org/show_bug.cgi?id=421374#c8.  The command correctly runs in a terminal.

REPOSITORY
  R241 KIO

REVISION DETAIL
  https://phabricator.kde.org/D29738

AFFECTED FILES
  src/core/desktopexecparser.cpp
  src/gui/kprocessrunner.cpp

To: marten, #frameworks, dfaure
Cc: kde-frameworks-devel, LeGast00n, cblack, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20200514/b36db5c4/attachment.htm>


More information about the Kde-frameworks-devel mailing list