mirror of
https://github.com/KDE/konsole.git
synced 2026-06-11 23:45:09 -04:00
Validate initial working directory Profile entry
Verify the Profile's initial working directory exists and is a dir This applies to KonsolePart as well as Konsole
This commit is contained in:
@@ -139,6 +139,7 @@ void Part::showShellInDir(const QString& dir)
|
||||
if (activeSession()->isRunning())
|
||||
return;
|
||||
|
||||
// All other checking is done in setInitialWorkingDirectory()
|
||||
if (!dir.isEmpty())
|
||||
activeSession()->setInitialWorkingDirectory(dir);
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ void Session::setArguments(const QStringList& arguments)
|
||||
|
||||
void Session::setInitialWorkingDirectory(const QString& dir)
|
||||
{
|
||||
_initialWorkingDir = KShell::tildeExpand(ShellCommand::expand(dir));
|
||||
_initialWorkingDir = validDirectory(KShell::tildeExpand(ShellCommand::expand(dir)));
|
||||
}
|
||||
|
||||
QString Session::currentWorkingDirectory()
|
||||
@@ -1550,6 +1550,21 @@ void Session::restoreSession(KConfigGroup& group)
|
||||
if (!value.isEmpty()) setCodec(value.toUtf8());
|
||||
}
|
||||
|
||||
QString Session::validDirectory(const QString& dir) const
|
||||
{
|
||||
QString validDir = dir;
|
||||
if (validDir.isEmpty()) {
|
||||
validDir = QDir::currentPath();
|
||||
}
|
||||
|
||||
const QFileInfo fi(validDir);
|
||||
if (!fi.exists() || !fi.isDir()) {
|
||||
validDir = QDir::homePath();
|
||||
}
|
||||
|
||||
return validDir;
|
||||
}
|
||||
|
||||
SessionGroup::SessionGroup(QObject* parent)
|
||||
: QObject(parent), _masterMode(0)
|
||||
{
|
||||
|
||||
@@ -730,6 +730,8 @@ private:
|
||||
bool updateForegroundProcessInfo();
|
||||
void updateWorkingDirectory();
|
||||
|
||||
QString validDirectory(const QString& directory) const;
|
||||
|
||||
QUuid _uniqueIdentifier; // SHELL_SESSION_ID
|
||||
|
||||
Pty* _shellProcess;
|
||||
|
||||
Reference in New Issue
Block a user