forked from qt-creator/qt-creator
Utils: Move meta char policy handling from FilePath to ConsoleProcess
Currently the only place that's using it and the scope is much smaller. Change-Id: I1a43d14f0e2c69a16f76e6f83b82436bbeeac1c9 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -63,6 +63,7 @@ public:
|
||||
~ConsoleProcess() override;
|
||||
|
||||
void setCommand(const Utils::CommandLine &command);
|
||||
void setAbortOnMetaChars(bool abort);
|
||||
|
||||
void setWorkingDirectory(const QString &dir);
|
||||
QString workingDirectory() const;
|
||||
|
||||
@@ -60,6 +60,7 @@ struct ConsoleProcessPrivate {
|
||||
QTemporaryFile *m_tempFile = nullptr;
|
||||
QProcess::ProcessError m_error = QProcess::UnknownError;
|
||||
QString m_errorString;
|
||||
bool m_abortOnMetaChars = true;
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
QProcess m_process;
|
||||
|
||||
@@ -65,6 +65,11 @@ void ConsoleProcess::setCommand(const Utils::CommandLine &command)
|
||||
d->m_commandLine = command;
|
||||
}
|
||||
|
||||
void ConsoleProcess::setAbortOnMetaChars(bool abort)
|
||||
{
|
||||
d->m_abortOnMetaChars = abort;
|
||||
}
|
||||
|
||||
void ConsoleProcess::setSettings(QSettings *settings)
|
||||
{
|
||||
d->m_settings = settings;
|
||||
@@ -84,8 +89,8 @@ bool ConsoleProcess::start()
|
||||
HostOsInfo::hostOs(),
|
||||
&d->m_environment,
|
||||
&d->m_workingDir,
|
||||
d->m_commandLine.metaCharMode()
|
||||
== CommandLine::MetaCharMode::Abort);
|
||||
d->m_abortOnMetaChars);
|
||||
|
||||
QString pcmd;
|
||||
if (perr == QtcProcess::SplitOk) {
|
||||
pcmd = d->m_commandLine.executable().toString();
|
||||
|
||||
@@ -86,9 +86,8 @@ CommandLine::CommandLine(const QString &exe, const QStringList &args)
|
||||
: CommandLine(FilePath::fromString(exe), args)
|
||||
{}
|
||||
|
||||
CommandLine::CommandLine(const FilePath &exe, const QStringList &args, MetaCharMode metaCharMode)
|
||||
CommandLine::CommandLine(const FilePath &exe, const QStringList &args)
|
||||
: m_executable(exe)
|
||||
, m_metaCharMode(metaCharMode)
|
||||
{
|
||||
addArgs(args);
|
||||
}
|
||||
|
||||
@@ -132,15 +132,12 @@ class QTCREATOR_UTILS_EXPORT CommandLine
|
||||
{
|
||||
public:
|
||||
enum RawType { Raw };
|
||||
enum class MetaCharMode { Abort, Ignore };
|
||||
|
||||
CommandLine() {}
|
||||
explicit CommandLine(const QString &executable);
|
||||
explicit CommandLine(const FilePath &executable);
|
||||
CommandLine(const QString &exe, const QStringList &args);
|
||||
CommandLine(const FilePath &exe,
|
||||
const QStringList &args,
|
||||
MetaCharMode metaCharMode = MetaCharMode::Abort);
|
||||
CommandLine(const FilePath &exe, const QStringList &args);
|
||||
CommandLine(const FilePath &exe, const QString &unparsedArgs, RawType);
|
||||
|
||||
void addArg(const QString &arg, OsType osType = HostOsInfo::hostOs());
|
||||
@@ -152,13 +149,11 @@ public:
|
||||
|
||||
FilePath executable() const { return m_executable; }
|
||||
QString arguments() const { return m_arguments; }
|
||||
MetaCharMode metaCharMode() const { return m_metaCharMode; }
|
||||
QStringList splitArguments(OsType osType = HostOsInfo::hostOs()) const;
|
||||
|
||||
private:
|
||||
FilePath m_executable;
|
||||
QString m_arguments;
|
||||
MetaCharMode m_metaCharMode;
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT FileUtils {
|
||||
|
||||
@@ -201,9 +201,8 @@ void SshDeviceProcess::handleConnected()
|
||||
this, &SshDeviceProcess::handleProcessStarted);
|
||||
connect(&d->consoleProcess, &ConsoleProcess::stubStopped,
|
||||
this, [this] { handleProcessFinished(d->consoleProcess.errorString()); });
|
||||
d->consoleProcess.setCommand({FilePath::fromString(cmdLine.first()),
|
||||
cmdLine.mid(1),
|
||||
CommandLine::MetaCharMode::Ignore});
|
||||
d->consoleProcess.setAbortOnMetaChars(false);
|
||||
d->consoleProcess.setCommand({cmdLine.first(), cmdLine.mid(1)});
|
||||
d->consoleProcess.start();
|
||||
} else {
|
||||
connect(d->process.get(), &QSsh::SshRemoteProcess::started,
|
||||
|
||||
Reference in New Issue
Block a user