forked from qt-creator/qt-creator
Get rid of QtcProcess::workingDirectory() overload
Adapt all callers' code so that it passes the FilePath instead of QString. As a consequence introduce TemporaryDirectory::masterDirectoryFilePath() and use it where easily possible. Change-Id: I14564949b3b916921e32a2957c84c03d1da43af2 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -678,11 +678,6 @@ void QtcProcess::setWorkingDirectory(const FilePath &dir)
|
||||
d->m_workingDirectory = dir;
|
||||
}
|
||||
|
||||
void QtcProcess::setWorkingDirectory(const QString &dir)
|
||||
{
|
||||
setWorkingDirectory(FilePath::fromString(dir));
|
||||
}
|
||||
|
||||
void QtcProcess::setUseCtrlCStub(bool enabled)
|
||||
{
|
||||
// Do not use the stub in debug mode. Activating the stub will shut down
|
||||
|
@@ -99,7 +99,6 @@ public:
|
||||
|
||||
FilePath workingDirectory() const;
|
||||
void setWorkingDirectory(const FilePath &dir);
|
||||
void setWorkingDirectory(const QString &dir); // FIXME: Kept to ease downstream transition
|
||||
|
||||
void setUseCtrlCStub(bool enabled);
|
||||
void setLowPriority();
|
||||
|
@@ -66,6 +66,11 @@ QString TemporaryDirectory::masterDirectoryPath()
|
||||
return m_masterTemporaryDir->path();
|
||||
}
|
||||
|
||||
FilePath TemporaryDirectory::masterDirectoryFilePath()
|
||||
{
|
||||
return FilePath::fromString(TemporaryDirectory::masterDirectoryPath());
|
||||
}
|
||||
|
||||
FilePath TemporaryDirectory::path() const
|
||||
{
|
||||
return FilePath::fromString(QTemporaryDir::path());
|
||||
|
@@ -41,6 +41,7 @@ public:
|
||||
static QTemporaryDir *masterTemporaryDirectory();
|
||||
static void setMasterTemporaryDirectory(const QString &pattern);
|
||||
static QString masterDirectoryPath();
|
||||
static FilePath masterDirectoryFilePath();
|
||||
|
||||
FilePath path() const;
|
||||
FilePath filePath(const QString &fileName) const;
|
||||
|
@@ -51,7 +51,7 @@ static void runProcess(QFutureInterface<void> &future,
|
||||
{
|
||||
const QString viewRoot = ClearCasePlugin::viewData().root;
|
||||
QtcProcess process;
|
||||
process.setWorkingDirectory(viewRoot);
|
||||
process.setWorkingDirectory(FilePath::fromString(viewRoot));
|
||||
process.setCommand({FilePath::fromString(settings.ccBinaryPath), args});
|
||||
process.start();
|
||||
if (!process.waitForStarted())
|
||||
|
@@ -935,7 +935,7 @@ void CMakeBuildSystem::runCTest()
|
||||
QTC_ASSERT(parameters.isValid(), return);
|
||||
|
||||
const CommandLine cmd { m_ctestPath, { "-N", "--show-only=json-v1" } };
|
||||
const QString workingDirectory = buildDirectory(parameters).toString();
|
||||
const FilePath workingDirectory = buildDirectory(parameters);
|
||||
const Environment environment = cmakeBuildConfiguration()->environment();
|
||||
|
||||
auto future = Utils::runAsync([cmd, workingDirectory, environment]
|
||||
|
@@ -1994,8 +1994,8 @@ void DebuggerPluginPrivate::dumpLog()
|
||||
LogWindow *logWindow = engine->logWindow();
|
||||
QTC_ASSERT(logWindow, return);
|
||||
|
||||
FilePath filePath = FileUtils::getSaveFilePath(nullptr, tr("Save Debugger Log"),
|
||||
FilePath::fromString(TemporaryDirectory::masterDirectoryPath()));
|
||||
const FilePath filePath = FileUtils::getSaveFilePath(nullptr, tr("Save Debugger Log"),
|
||||
TemporaryDirectory::masterDirectoryFilePath());
|
||||
if (filePath.isEmpty())
|
||||
return;
|
||||
FileSaver saver(filePath);
|
||||
|
@@ -134,7 +134,7 @@ private:
|
||||
m_tempCoreFilePath = FilePath::fromString(tmp.fileName());
|
||||
}
|
||||
|
||||
m_coreUnpackProcess.setWorkingDirectory(FilePath::fromString(TemporaryDirectory::masterDirectoryPath()));
|
||||
m_coreUnpackProcess.setWorkingDirectory(TemporaryDirectory::masterDirectoryFilePath());
|
||||
connect(&m_coreUnpackProcess, &QtcProcess::finished, this, &CoreUnpacker::reportStarted);
|
||||
|
||||
const QString msg = DebuggerRunTool::tr("Unpacking core file to %1");
|
||||
|
@@ -153,7 +153,7 @@ CdbSymbolPathListEditor::CdbSymbolPathListEditor(QWidget *parent) :
|
||||
bool CdbSymbolPathListEditor::promptCacheDirectory(QWidget *parent, FilePath *cacheDirectory)
|
||||
{
|
||||
CacheDirectoryDialog dialog(parent);
|
||||
dialog.setPath(FilePath::fromString(TemporaryDirectory::masterDirectoryPath()) + "/symbolcache");
|
||||
dialog.setPath(TemporaryDirectory::masterDirectoryFilePath() + "/symbolcache");
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return false;
|
||||
*cacheDirectory = dialog.path();
|
||||
@@ -179,7 +179,7 @@ void CdbSymbolPathListEditor::setupSymbolPaths()
|
||||
if (path.isEmpty() && indexOfSymbolCache != -1)
|
||||
path = FilePath::fromString(currentPaths.at(indexOfSymbolCache));
|
||||
if (path.isEmpty())
|
||||
path = FilePath::fromString(TemporaryDirectory::masterDirectoryPath() + "/symbolcache");
|
||||
path = TemporaryDirectory::masterDirectoryFilePath() + "/symbolcache";
|
||||
|
||||
bool useSymbolServer = true;
|
||||
bool useSymbolCache = true;
|
||||
|
@@ -1721,7 +1721,7 @@ bool DockerDevicePrivate::runInContainer(const CommandLine &cmd) const
|
||||
|
||||
QtcProcess proc;
|
||||
proc.setCommand(dcmd);
|
||||
proc.setWorkingDirectory(QDir::tempPath());
|
||||
proc.setWorkingDirectory(FilePath::fromString(QDir::tempPath()));
|
||||
proc.start();
|
||||
proc.waitForFinished();
|
||||
|
||||
|
@@ -59,7 +59,7 @@ bool MergeTool::start(const FilePath &workingDirectory, const QStringList &files
|
||||
env.set("LANG", "C");
|
||||
env.set("LANGUAGE", "C");
|
||||
m_process = new QtcProcess(ProcessMode::Writer);
|
||||
m_process->setWorkingDirectory(workingDirectory.toString());
|
||||
m_process->setWorkingDirectory(workingDirectory);
|
||||
m_process->setEnvironment(env);
|
||||
m_process->setProcessChannelMode(QProcess::MergedChannels);
|
||||
const Utils::FilePath binary = GitClient::instance()->vcsBinary();
|
||||
|
@@ -113,12 +113,12 @@ bool StdIOClientInterface::start()
|
||||
return true;
|
||||
}
|
||||
|
||||
void StdIOClientInterface::setCommandLine(const Utils::CommandLine &cmd)
|
||||
void StdIOClientInterface::setCommandLine(const CommandLine &cmd)
|
||||
{
|
||||
m_process.setCommand(cmd);
|
||||
}
|
||||
|
||||
void StdIOClientInterface::setWorkingDirectory(const QString &workingDirectory)
|
||||
void StdIOClientInterface::setWorkingDirectory(const FilePath &workingDirectory)
|
||||
{
|
||||
m_process.setWorkingDirectory(workingDirectory);
|
||||
}
|
||||
|
@@ -80,7 +80,7 @@ public:
|
||||
|
||||
// These functions only have an effect if they are called before start
|
||||
void setCommandLine(const Utils::CommandLine &cmd);
|
||||
void setWorkingDirectory(const QString &workingDirectory);
|
||||
void setWorkingDirectory(const Utils::FilePath &workingDirectory);
|
||||
|
||||
protected:
|
||||
void sendData(const QByteArray &data) final;
|
||||
|
@@ -743,7 +743,7 @@ BaseClientInterface *StdIOSettings::createInterfaceWithProject(ProjectExplorer::
|
||||
auto interface = new StdIOClientInterface;
|
||||
interface->setCommandLine(command());
|
||||
if (project)
|
||||
interface->setWorkingDirectory(project->projectDirectory().toString());
|
||||
interface->setWorkingDirectory(project->projectDirectory());
|
||||
return interface;
|
||||
}
|
||||
|
||||
|
@@ -300,13 +300,13 @@ public:
|
||||
const QByteArray &stdInput = {},
|
||||
QTextCodec *outputCodec = nullptr) const;
|
||||
|
||||
PerforceResponse synchronousProcess(const QString &workingDir,
|
||||
PerforceResponse synchronousProcess(const FilePath &workingDir,
|
||||
const QStringList &args,
|
||||
unsigned flags,
|
||||
const QByteArray &stdInput,
|
||||
QTextCodec *outputCodec) const;
|
||||
|
||||
PerforceResponse fullySynchronousProcess(const QString &workingDir,
|
||||
PerforceResponse fullySynchronousProcess(const FilePath &workingDir,
|
||||
const QStringList &args,
|
||||
unsigned flags,
|
||||
const QByteArray &stdInput,
|
||||
@@ -1238,7 +1238,7 @@ static inline QString msgExitCode(int ex)
|
||||
}
|
||||
|
||||
// Run using a SynchronousProcess, emitting signals to the message window
|
||||
PerforceResponse PerforcePluginPrivate::synchronousProcess(const QString &workingDir,
|
||||
PerforceResponse PerforcePluginPrivate::synchronousProcess(const FilePath &workingDir,
|
||||
const QStringList &args,
|
||||
unsigned flags,
|
||||
const QByteArray &stdInput,
|
||||
@@ -1300,7 +1300,7 @@ PerforceResponse PerforcePluginPrivate::synchronousProcess(const QString &workin
|
||||
}
|
||||
|
||||
// Run using a QProcess, for short queries
|
||||
PerforceResponse PerforcePluginPrivate::fullySynchronousProcess(const QString &workingDir,
|
||||
PerforceResponse PerforcePluginPrivate::fullySynchronousProcess(const FilePath &workingDir,
|
||||
const QStringList &args,
|
||||
unsigned flags,
|
||||
const QByteArray &stdInput,
|
||||
@@ -1388,8 +1388,8 @@ PerforceResponse PerforcePluginPrivate::runP4Cmd(const FilePath &workingDir,
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
|
||||
const PerforceResponse response = (flags & RunFullySynchronous) ?
|
||||
fullySynchronousProcess(workingDir.toString(), actualArgs, flags, stdInput, outputCodec) :
|
||||
synchronousProcess(workingDir.toString(), actualArgs, flags, stdInput, outputCodec);
|
||||
fullySynchronousProcess(workingDir, actualArgs, flags, stdInput, outputCodec) :
|
||||
synchronousProcess(workingDir, actualArgs, flags, stdInput, outputCodec);
|
||||
|
||||
if (flags & ShowBusyCursor)
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
@@ -78,7 +78,7 @@ QStringList fixGeneratorScript(const QString &configFile, QString binary)
|
||||
|
||||
// Helper for running the optional generation script.
|
||||
static bool
|
||||
runGenerationScriptHelper(const QString &workingDirectory,
|
||||
runGenerationScriptHelper(const FilePath &workingDirectory,
|
||||
const QStringList &script,
|
||||
const QList<GeneratorScriptArgument> &argumentsIn,
|
||||
bool dryRun,
|
||||
@@ -112,7 +112,7 @@ static bool
|
||||
process.setTimeoutS(30);
|
||||
const Utils::CommandLine cmd(FilePath::fromString(binary), arguments);
|
||||
if (CustomWizard::verbose())
|
||||
qDebug("In %s, running:\n%s\n", qPrintable(workingDirectory),
|
||||
qDebug("In %s, running:\n%s\n", qPrintable(workingDirectory.toUserOutput()),
|
||||
qPrintable(cmd.toUserOutput()));
|
||||
process.setCommand(cmd);
|
||||
process.setProcessUserEventWhileRunning();
|
||||
@@ -150,7 +150,7 @@ Core::GeneratedFiles
|
||||
{
|
||||
// Run in temporary directory as the target path may not exist yet.
|
||||
QString stdOut;
|
||||
if (!runGenerationScriptHelper(Utils::TemporaryDirectory::masterDirectoryPath(),
|
||||
if (!runGenerationScriptHelper(Utils::TemporaryDirectory::masterDirectoryFilePath(),
|
||||
script, arguments, true, fieldMap, &stdOut, errorMessage))
|
||||
return Core::GeneratedFiles();
|
||||
Core::GeneratedFiles files;
|
||||
@@ -232,7 +232,7 @@ bool runCustomWizardGeneratorScript(const QString &targetPath,
|
||||
const QMap<QString, QString> &fieldMap,
|
||||
QString *errorMessage)
|
||||
{
|
||||
return runGenerationScriptHelper(targetPath, script, arguments,
|
||||
return runGenerationScriptHelper(FilePath::fromString(targetPath), script, arguments,
|
||||
false, fieldMap,
|
||||
nullptr, errorMessage);
|
||||
}
|
||||
|
@@ -415,7 +415,7 @@ void ProcessExtraCompiler::runInThread(
|
||||
|
||||
process.setEnvironment(env);
|
||||
if (!workDir.isEmpty())
|
||||
process.setWorkingDirectory(workDir.toString());
|
||||
process.setWorkingDirectory(workDir);
|
||||
process.setCommand({ cmd, args });
|
||||
process.setWriteData(sourceContents);
|
||||
process.start();
|
||||
|
@@ -638,7 +638,7 @@ Macros MsvcToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
|
||||
}
|
||||
Utils::QtcProcess cpp;
|
||||
cpp.setEnvironment(env);
|
||||
cpp.setWorkingDirectory(Utils::TemporaryDirectory::masterDirectoryPath());
|
||||
cpp.setWorkingDirectory(Utils::TemporaryDirectory::masterDirectoryFilePath());
|
||||
QStringList arguments;
|
||||
const Utils::FilePath binary = env.searchInPath(QLatin1String("cl.exe"));
|
||||
if (binary.isEmpty()) {
|
||||
@@ -1766,7 +1766,7 @@ Macros ClangClToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
|
||||
|
||||
QtcProcess cpp;
|
||||
cpp.setEnvironment(env);
|
||||
cpp.setWorkingDirectory(Utils::TemporaryDirectory::masterDirectoryPath());
|
||||
cpp.setWorkingDirectory(Utils::TemporaryDirectory::masterDirectoryFilePath());
|
||||
|
||||
QStringList arguments = cxxflags;
|
||||
arguments.append(gccPredefinedMacrosOptions(language()));
|
||||
|
@@ -69,7 +69,7 @@ WinRtRunnerHelper::WinRtRunnerHelper(ProjectExplorer::RunWorker *runWorker, QStr
|
||||
return;
|
||||
}
|
||||
|
||||
m_executableFilePath = runControl->targetFilePath().toString();
|
||||
m_executableFilePath = runControl->targetFilePath();
|
||||
|
||||
if (m_executableFilePath.isEmpty()) {
|
||||
*errorMessage = tr("Cannot determine the executable file path for \"%1\".")
|
||||
@@ -79,8 +79,7 @@ WinRtRunnerHelper::WinRtRunnerHelper(ProjectExplorer::RunWorker *runWorker, QStr
|
||||
|
||||
// ### we should not need to append ".exe" here.
|
||||
if (!m_executableFilePath.endsWith(QLatin1String(".exe")))
|
||||
m_executableFilePath += QStringLiteral(".exe");
|
||||
|
||||
m_executableFilePath = m_executableFilePath + QStringLiteral(".exe");
|
||||
|
||||
bool loopbackExemptClient = false;
|
||||
bool loopbackExemptServer = false;
|
||||
@@ -205,7 +204,7 @@ void WinRtRunnerHelper::startWinRtRunner(const RunConf &conf)
|
||||
cmdLine.addArgs({"--profile", "appxphone"});
|
||||
|
||||
cmdLine.addArgs(m_loopbackArguments);
|
||||
cmdLine.addArg(m_executableFilePath);
|
||||
cmdLine.addArg(m_executableFilePath.toString());
|
||||
cmdLine.addArgs(m_arguments, CommandLine::Raw);
|
||||
|
||||
appendMessage(cmdLine.toUserOutput(), NormalMessageFormat);
|
||||
@@ -221,6 +220,6 @@ void WinRtRunnerHelper::startWinRtRunner(const RunConf &conf)
|
||||
process->setUseCtrlCStub(true);
|
||||
process->setCommand(cmdLine);
|
||||
process->setEnvironment(m_worker->runControl()->buildEnvironment());
|
||||
process->setWorkingDirectory(QFileInfo(m_executableFilePath).absolutePath());
|
||||
process->setWorkingDirectory(m_executableFilePath.absolutePath());
|
||||
process->start();
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include "winrtdevice.h"
|
||||
|
||||
#include <utils/environment.h>
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/outputformat.h>
|
||||
|
||||
#include <QObject>
|
||||
@@ -72,7 +73,7 @@ private:
|
||||
ProjectExplorer::RunWorker *m_worker = nullptr;
|
||||
WinRtDevice::ConstPtr m_device;
|
||||
QString m_runnerFilePath;
|
||||
QString m_executableFilePath;
|
||||
Utils::FilePath m_executableFilePath;
|
||||
QString m_debuggerExecutable;
|
||||
QString m_debuggerArguments;
|
||||
QString m_arguments;
|
||||
|
Reference in New Issue
Block a user