From c0217c6e5e1e7592fcd0d808f1766e8be6289db0 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 4 Jul 2014 22:59:48 +0200 Subject: [PATCH 04/10] When executing commands set the working directory to be the current directory if not specified by the service. Forward port commit 89d4585 by Dawit which fixes #142597. + fix path() to toLocalFile(). REVIEW: 119020 --- src/widgets/krun.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/widgets/krun.cpp b/src/widgets/krun.cpp index 77708a0..bc39d83 100644 --- a/src/widgets/krun.cpp +++ b/src/widgets/krun.cpp @@ -176,7 +176,8 @@ bool KRun::runUrl(const QUrl &u, const QString &_mimetype, QWidget *window, bool } else if (isExecutableFile(u, _mimetype)) { if (u.isLocalFile() && runExecutables) { if (KAuthorized::authorize("shell_access")) { - return (KRun::runCommand(KShell::quoteArg(u.toLocalFile()), QString(), QString(), window, asn, u.adjusted(QUrl::RemoveFilename).path())); // just execute the url as a command + return (KRun::runCommand(KShell::quoteArg(u.toLocalFile()), QString(), QString(), + window, asn, u.adjusted(QUrl::RemoveFilename).toLocalFile())); // just execute the url as a command // ## TODO implement deleting the file if tempFile==true } else { noAuth = true; @@ -426,8 +427,13 @@ static bool runTempService(const KService &_service, const QList &_urls, Q } //qDebug() << "runTempService: KProcess args=" << args; + QString path(_service.path()); + if (path.isEmpty() && !_urls.isEmpty() && _urls.first().isLocalFile()) { + path = _urls.first().adjusted(QUrl::RemoveFilename).toLocalFile(); + } + return runCommandInternal(args.join(" "), &_service, KIO::DesktopExecParser::executablePath(_service.exec()), - _service.name(), _service.icon(), window, asn, _service.path()); + _service.name(), _service.icon(), window, asn, path); } // WARNING: don't call this from DesktopExecParser, since klauncher uses that too... -- 2.0.0