forked from qt-creator/qt-creator
Utils: Add combine with device env option
Adds the option Environment::combineWithDeviceEnvironment. This allows the linuxdevice to set it to false. Without this option a deadlock would occur when the QtcProcess tries to get the device environment and the device shell failed to start. (e.g. because a required command is missing on the device). Change-Id: I8f7550d0d90e989a339f27e993a836e67e910e33 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -359,6 +359,8 @@ public:
|
||||
RunResult runInShell(const CommandLine &cmdLine,
|
||||
const QByteArray &stdInData) const override;
|
||||
|
||||
Environment deviceEnvironment() const override;
|
||||
|
||||
LinuxDevicePrivate *m_dev;
|
||||
};
|
||||
|
||||
@@ -388,6 +390,19 @@ RunResult LinuxDeviceFileAccess::runInShell(const CommandLine &cmdLine,
|
||||
return m_dev->runInShell(cmdLine, stdInData);
|
||||
}
|
||||
|
||||
Environment LinuxDeviceFileAccess::deviceEnvironment() const
|
||||
{
|
||||
QtcProcess getEnvProc;
|
||||
getEnvProc.setCommand({FilePath("env").onDevice(m_dev->q->rootPath()), {}});
|
||||
Environment inEnv;
|
||||
inEnv.setCombineWithDeviceEnvironment(false);
|
||||
getEnvProc.setEnvironment(inEnv);
|
||||
getEnvProc.runBlocking();
|
||||
|
||||
const QString remoteOutput = getEnvProc.cleanedStdOut();
|
||||
return Environment(remoteOutput.split('\n', Qt::SkipEmptyParts), m_dev->q->osType());
|
||||
}
|
||||
|
||||
// SshProcessImpl
|
||||
|
||||
class SshProcessInterfacePrivate : public QObject
|
||||
|
||||
Reference in New Issue
Block a user