diff options
author | David Schulz <david.schulz@qt.io> | 2022-06-15 13:10:26 +0200 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2022-06-27 11:23:54 +0000 |
commit | 1956fa03659bb4cd225cb66c712c0319615d0685 (patch) | |
tree | 00d7c8bd225aede76fb03822752f74ad74231870 | |
parent | e7d90c23b6275a56cb63ec40792faaa615003f67 (diff) |
Python: prevent setting local env to remote pyls
Change-Id: Id0eea5420c897687e6931bf640e3a37ba2638b8f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r-- | src/plugins/languageclient/languageclientinterface.cpp | 7 | ||||
-rw-r--r-- | src/plugins/languageclient/languageclientinterface.h | 2 | ||||
-rw-r--r-- | src/plugins/python/pythonlanguageclient.cpp | 20 |
3 files changed, 17 insertions, 12 deletions
diff --git a/src/plugins/languageclient/languageclientinterface.cpp b/src/plugins/languageclient/languageclientinterface.cpp index c20fa7c121..b7e4a9ebb7 100644 --- a/src/plugins/languageclient/languageclientinterface.cpp +++ b/src/plugins/languageclient/languageclientinterface.cpp @@ -99,10 +99,6 @@ void BaseClientInterface::parseCurrentMessage() m_currentMessage = BaseMessage(); } -StdIOClientInterface::StdIOClientInterface() - : m_env(Utils::Environment::systemEnvironment()) -{} - StdIOClientInterface::~StdIOClientInterface() { delete m_process; @@ -128,7 +124,8 @@ void StdIOClientInterface::startImpl() }); m_process->setCommand(m_cmd); m_process->setWorkingDirectory(m_workingDirectory); - m_process->setEnvironment(m_env); + if (m_env.isValid()) + m_process->setEnvironment(m_env); m_process->start(); } diff --git a/src/plugins/languageclient/languageclientinterface.h b/src/plugins/languageclient/languageclientinterface.h index 0482c0e834..4aa683f180 100644 --- a/src/plugins/languageclient/languageclientinterface.h +++ b/src/plugins/languageclient/languageclientinterface.h @@ -72,7 +72,7 @@ class LANGUAGECLIENT_EXPORT StdIOClientInterface : public BaseClientInterface { Q_OBJECT public: - StdIOClientInterface(); + StdIOClientInterface() = default; ~StdIOClientInterface() override; StdIOClientInterface(const StdIOClientInterface &) = delete; diff --git a/src/plugins/python/pythonlanguageclient.cpp b/src/plugins/python/pythonlanguageclient.cpp index 2a4ea8c7d9..e621cd6283 100644 --- a/src/plugins/python/pythonlanguageclient.cpp +++ b/src/plugins/python/pythonlanguageclient.cpp @@ -153,14 +153,22 @@ class PyLSInterface : public StdIOClientInterface public: PyLSInterface() : m_extraPythonPath("QtCreator-pyls-XXXXXX") + { } + + TemporaryDirectory m_extraPythonPath; +protected: + void startImpl() override { - Environment env = Environment::systemEnvironment(); - env.appendOrSet("PYTHONPATH", - m_extraPythonPath.path().toString(), - OsSpecificAspects::pathListSeparator(env.osType())); - setEnvironment(env); + if (!m_cmd.executable().needsDevice()) { + // todo check where to put this tempdir in remote setups + Environment env = Environment::systemEnvironment(); + env.appendOrSet("PYTHONPATH", + m_extraPythonPath.path().toString(), + OsSpecificAspects::pathListSeparator(env.osType())); + setEnvironment(env); + } + StdIOClientInterface::startImpl(); } - TemporaryDirectory m_extraPythonPath; }; PyLSClient *clientForPython(const FilePath &python) |