Python: Fix python run configuration

Add the WorkingDirectoryAspect to prevent running the
main script in an unpredictable location.

Change-Id: I1be206261b7983e933b53ccd57c93089154d8417
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
This commit is contained in:
David Schulz
2019-11-14 14:22:28 +01:00
parent 775c78eca8
commit 40612bceee

View File

@@ -274,6 +274,7 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Core::Id id)
auto argumentsAspect = addAspect<ArgumentsAspect>(); auto argumentsAspect = addAspect<ArgumentsAspect>();
addAspect<WorkingDirectoryAspect>();
addAspect<TerminalAspect>(); addAspect<TerminalAspect>();
setCommandLineGetter([this, interpreterAspect, argumentsAspect] { setCommandLineGetter([this, interpreterAspect, argumentsAspect] {
@@ -305,6 +306,9 @@ void PythonRunConfiguration::updateLanguageServer()
PyLSConfigureAssistant::instance()->openDocumentWithPython(python, document); PyLSConfigureAssistant::instance()->openDocumentWithPython(python, document);
} }
} }
aspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(
Utils::FilePath::fromString(mainScript()).parentDir());
} }
bool PythonRunConfiguration::supportsDebugger() const bool PythonRunConfiguration::supportsDebugger() const