File kdelibs-trinity-konq-working-dir.diff of Package kdelibs3
commit dbeab1b28062eafaa59edc13509ba3a348ed1853
Author: tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>
Date: 1270490101 +0000
Set the working directory to the same directory as the executable when running an executable directly in konqueror
Fixes Bug 168
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1111449 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
diff --git a/kio/kio/krun.cpp b/kio/kio/krun.cpp
index 6acfb3b..8384e2c 100644
--- a/kio/kio/krun.cpp
+++ b/kio/kio/krun.cpp
@@ -853,8 +853,11 @@ pid_t KRun::runCommand( const QString& cmd, const QString &execName, const QStri
proc->setUseShell(true);
*proc << cmd;
KService::Ptr service = KService::serviceByDesktopName( binaryName( execName, true ) );
- return runCommandInternal( proc, service.data(), binaryName( execName, false ), execName, iconName,
- window, asn );
+ QStringList args = KShell::splitArgs( cmd );
+ for (QStringList::ConstIterator it = args.begin(); it != args.end(); ++it)
+ if (!(*it).contains('='))
+ proc->setWorkingDirectory((*it).mid(0, (*it).findRev('/')));
+ return runCommandInternal( proc, service.data(), binaryName( execName, false ), execName, iconName, window, asn );
}
KRun::KRun( const KURL& url, mode_t mode, bool isLocalFile, bool showProgressInfo )