diff options
author | hjk <hjk@qt.io> | 2021-08-02 18:02:10 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2021-08-06 12:51:24 +0000 |
commit | 4a42bcd4e8d2c73be426775597e8a58f5df6a3a8 (patch) | |
tree | 9def81512c2a914cdec059587dca6135c38e0e15 | |
parent | b8f369c436cddd0323ea752a6c1b623431cb5096 (diff) | |
download | qt-creator-4a42bcd4e8d2c73be426775597e8a58f5df6a3a8.tar.gz |
Utils/ProjectExplorer: Use FilePath for Runnable::workingDirectory
... and in some using code.
Change-Id: I231ea56628908f7d305d13f07eabe8803fe8a791
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
44 files changed, 92 insertions, 80 deletions
diff --git a/src/libs/utils/commandline.cpp b/src/libs/utils/commandline.cpp index da44b02e08..baa848f9e4 100644 --- a/src/libs/utils/commandline.cpp +++ b/src/libs/utils/commandline.cpp @@ -589,12 +589,20 @@ static QString quoteArgWin(const QString &arg) } ProcessArgs ProcessArgs::prepareArgs(const QString &cmd, SplitError *err, OsType osType, - const Environment *env, const QString *pwd, bool abortOnMeta) + const Environment *env, const FilePath *pwd, bool abortOnMeta) { + QString wdcopy; + QString *wd = nullptr; + if (pwd) { + wdcopy = pwd->toString(); + wd = &wdcopy; + } + ProcessArgs res; if (osType == OsTypeWindows) - return prepareArgsWin(cmd, err, env, pwd); + res = prepareArgsWin(cmd, err, env, wd); else - return createUnixArgs(splitArgs(cmd, osType, abortOnMeta, err, env, pwd)); + res = createUnixArgs(splitArgs(cmd, osType, abortOnMeta, err, env, wd)); + return res; } QString ProcessArgs::quoteArg(const QString &arg, OsType osType) @@ -637,7 +645,7 @@ void ProcessArgs::addArgs(QString *args, const QStringList &inArgs) bool ProcessArgs::prepareCommand(const QString &command, const QString &arguments, QString *outCmd, ProcessArgs *outArgs, OsType osType, - const Environment *env, const QString *pwd) + const Environment *env, const FilePath *pwd) { ProcessArgs::SplitError err; *outArgs = ProcessArgs::prepareArgs(arguments, &err, osType, env, pwd); diff --git a/src/libs/utils/commandline.h b/src/libs/utils/commandline.h index a2a43a82e1..99c7377f44 100644 --- a/src/libs/utils/commandline.h +++ b/src/libs/utils/commandline.h @@ -64,12 +64,12 @@ public: //! Prepare argument of a shell command for feeding into QProcess static ProcessArgs prepareArgs(const QString &cmd, SplitError *err, OsType osType = HostOsInfo::hostOs(), - const Environment *env = nullptr, const QString *pwd = nullptr, + const Environment *env = nullptr, const FilePath *pwd = nullptr, bool abortOnMeta = true); //! Prepare a shell command for feeding into QProcess static bool prepareCommand(const QString &command, const QString &arguments, QString *outCmd, ProcessArgs *outArgs, OsType osType = HostOsInfo::hostOs(), - const Environment *env = nullptr, const QString *pwd = nullptr); + const Environment *env = nullptr, const FilePath *pwd = nullptr); //! Quote and append each argument to a shell command static void addArgs(QString *args, const QStringList &inArgs); //! Append already quoted arguments to a shell command diff --git a/src/libs/utils/consoleprocess.cpp b/src/libs/utils/consoleprocess.cpp index 19f5f3a79f..6c50a95f21 100644 --- a/src/libs/utils/consoleprocess.cpp +++ b/src/libs/utils/consoleprocess.cpp @@ -83,7 +83,7 @@ public: static QString m_defaultConsoleProcess; ConsoleProcess::Mode m_mode = ConsoleProcess::Run; - QString m_workingDir; + FilePath m_workingDir; Environment m_environment; qint64 m_appPid = 0; int m_appCode; @@ -462,7 +462,7 @@ bool ConsoleProcess::start() d->m_pid = new PROCESS_INFORMATION; ZeroMemory(d->m_pid, sizeof(PROCESS_INFORMATION)); - QString workDir = QDir::toNativeSeparators(workingDirectory()); + QString workDir = workingDirectory().toUserOutput(); if (!workDir.isEmpty() && !workDir.endsWith(QLatin1Char('\\'))) workDir.append(QLatin1Char('\\')); @@ -583,7 +583,7 @@ bool ConsoleProcess::start() << modeOption(d->m_mode) << d->m_stubServer.fullServerName() << msgPromptToClose() - << workingDirectory() + << workingDirectory().path() << (d->m_tempFile ? d->m_tempFile->fileName() : QString()) << QString::number(getpid()) << pcmd @@ -958,12 +958,12 @@ QProcess::ExitStatus ConsoleProcess::exitStatus() const return d->m_appStatus; } -void ConsoleProcess::setWorkingDirectory(const QString &dir) +void ConsoleProcess::setWorkingDirectory(const FilePath &dir) { d->m_workingDir = dir; } -QString ConsoleProcess::workingDirectory() const +FilePath ConsoleProcess::workingDirectory() const { return d->m_workingDir; } @@ -1025,9 +1025,9 @@ QString ConsoleProcess::msgUnexpectedOutput(const QByteArray &what) return tr("Unexpected output from helper program (%1).").arg(QString::fromLatin1(what)); } -QString ConsoleProcess::msgCannotChangeToWorkDir(const QString & dir, const QString &why) +QString ConsoleProcess::msgCannotChangeToWorkDir(const FilePath &dir, const QString &why) { - return tr("Cannot change to working directory \"%1\": %2").arg(dir, why); + return tr("Cannot change to working directory \"%1\": %2").arg(dir.toString(), why); } QString ConsoleProcess::msgCannotExecute(const QString & p, const QString &why) diff --git a/src/libs/utils/consoleprocess.h b/src/libs/utils/consoleprocess.h index 16373fe76e..6fa519aea1 100644 --- a/src/libs/utils/consoleprocess.h +++ b/src/libs/utils/consoleprocess.h @@ -36,8 +36,9 @@ QT_END_NAMESPACE namespace Utils { -class Environment; class CommandLine; +class Environment; +class FilePath; class QTCREATOR_UTILS_EXPORT TerminalCommand { @@ -69,8 +70,8 @@ public: void setAbortOnMetaChars(bool abort); - void setWorkingDirectory(const QString &dir); - QString workingDirectory() const; + void setWorkingDirectory(const Utils::FilePath &dir); + Utils::FilePath workingDirectory() const; void setEnvironment(const Environment &env); Environment environment() const; @@ -135,7 +136,7 @@ private: static QString msgCannotWriteTempFile(); static QString msgCannotCreateTempDir(const QString & dir, const QString &why); static QString msgUnexpectedOutput(const QByteArray &what); - static QString msgCannotChangeToWorkDir(const QString & dir, const QString &why); + static QString msgCannotChangeToWorkDir(const Utils::FilePath &dir, const QString &why); static QString msgCannotExecute(const QString & p, const QString &why); void emitError(QProcess::ProcessError err, const QString &errorString); diff --git a/src/libs/utils/qtcprocess.cpp b/src/libs/utils/qtcprocess.cpp index a91b8cadac..87997f1e62 100644 --- a/src/libs/utils/qtcprocess.cpp +++ b/src/libs/utils/qtcprocess.cpp @@ -591,14 +591,14 @@ void QtcProcess::start() env = Environment::systemEnvironment(); } - const QString workDir = d->m_workingDirectory.path(); - d->m_process->setWorkingDirectory(workDir); + d->m_process->setWorkingDirectory(d->m_workingDirectory.path()); QString command; ProcessArgs arguments; bool success = ProcessArgs::prepareCommand(d->m_commandLine.executable().toString(), d->m_commandLine.arguments(), - &command, &arguments, osType, &env, &workDir); + &command, &arguments, osType, &env, + &d->m_workingDirectory); if (osType == OsTypeWindows) { QString args; if (d->m_useCtrlCStub) { diff --git a/src/plugins/autotest/ctest/ctesttreeitem.cpp b/src/plugins/autotest/ctest/ctesttreeitem.cpp index 382241b880..8a2c75127f 100644 --- a/src/plugins/autotest/ctest/ctesttreeitem.cpp +++ b/src/plugins/autotest/ctest/ctesttreeitem.cpp @@ -125,7 +125,7 @@ QList<ITestConfiguration *> CTestTreeItem::testConfigurationsFor(const QStringLi } const ProjectExplorer::BuildConfiguration *buildConfig = target->activeBuildConfiguration(); if (QTC_GUARD(buildConfig)) - config->setWorkingDirectory(buildConfig->buildDirectory().toString()); + config->setWorkingDirectory(buildConfig->buildDirectory()); if (selected.isEmpty()) config->setTestCaseCount(testBase()->asTestTool()->rootNode()->childCount()); diff --git a/src/plugins/autotest/testconfiguration.cpp b/src/plugins/autotest/testconfiguration.cpp index 1772e54fbf..1e36328884 100644 --- a/src/plugins/autotest/testconfiguration.cpp +++ b/src/plugins/autotest/testconfiguration.cpp @@ -57,7 +57,7 @@ ITestConfiguration::ITestConfiguration(Autotest::ITestBase *testBase) { } -void ITestConfiguration::setWorkingDirectory(const QString &workingDirectory) +void ITestConfiguration::setWorkingDirectory(const FilePath &workingDirectory) { m_runnable.workingDirectory = workingDirectory; } @@ -65,9 +65,8 @@ void ITestConfiguration::setWorkingDirectory(const QString &workingDirectory) Utils::FilePath ITestConfiguration::workingDirectory() const { if (!m_runnable.workingDirectory.isEmpty()) { - const QFileInfo info(m_runnable.workingDirectory); - if (info.isDir()) // ensure wanted working dir does exist - return Utils::FilePath::fromString(info.absoluteFilePath()); + if (m_runnable.workingDirectory.isDir()) // ensure wanted working dir does exist + return m_runnable.workingDirectory.absoluteFilePath(); } const Utils::FilePath executable = executableFilePath(); diff --git a/src/plugins/autotest/testconfiguration.h b/src/plugins/autotest/testconfiguration.h index 2d6c36544d..9ffa1a1bc2 100644 --- a/src/plugins/autotest/testconfiguration.h +++ b/src/plugins/autotest/testconfiguration.h @@ -60,7 +60,7 @@ public: void setEnvironment(const Utils::Environment &env) { m_runnable.environment = env; } Utils::Environment environment() const { return m_runnable.environment; } - void setWorkingDirectory(const QString &workingDirectory); + void setWorkingDirectory(const Utils::FilePath &workingDirectory); Utils::FilePath workingDirectory() const; bool hasExecutable() const; Utils::FilePath executableFilePath() const; diff --git a/src/plugins/autotest/testrunconfiguration.h b/src/plugins/autotest/testrunconfiguration.h index 3c8a041f8e..f0f56f219a 100644 --- a/src/plugins/autotest/testrunconfiguration.h +++ b/src/plugins/autotest/testrunconfiguration.h @@ -67,7 +67,7 @@ public: QTC_ASSERT(m_testConfig, return r); r.executable = m_testConfig->executableFilePath(); r.commandLineArguments = m_testConfig->argumentsForTestRunner().join(' '); - r.workingDirectory = m_testConfig->workingDirectory().toString(); + r.workingDirectory = m_testConfig->workingDirectory(); r.environment = m_testConfig->environment(); return r; } diff --git a/src/plugins/autotest/testrunner.cpp b/src/plugins/autotest/testrunner.cpp index a0b00f7d37..88a1359fc1 100644 --- a/src/plugins/autotest/testrunner.cpp +++ b/src/plugins/autotest/testrunner.cpp @@ -911,7 +911,7 @@ void RunConfigurationSelectionDialog::populate() auto runnable = rc->runnable(); const QStringList rcDetails = { runnable.executable.toString(), runnable.commandLineArguments, - runnable.workingDirectory }; + runnable.workingDirectory.toString() }; m_rcCombo->addItem(rc->displayName(), rcDetails); } } diff --git a/src/plugins/boot2qt/qdbstopapplicationservice.cpp b/src/plugins/boot2qt/qdbstopapplicationservice.cpp index e0a683cc61..d300ef08ad 100644 --- a/src/plugins/boot2qt/qdbstopapplicationservice.cpp +++ b/src/plugins/boot2qt/qdbstopapplicationservice.cpp @@ -32,6 +32,8 @@ #include <projectexplorer/runcontrol.h> #include <projectexplorer/target.h> +using namespace Utils; + namespace Qdb { namespace Internal { @@ -102,7 +104,7 @@ void QdbStopApplicationService::doDeploy() ProjectExplorer::Runnable runnable; runnable.executable = Utils::FilePath::fromString(Constants::AppcontrollerFilepath); runnable.commandLineArguments = QStringLiteral("--stop"); - runnable.workingDirectory = QStringLiteral("/usr/bin"); + runnable.workingDirectory = FilePath::fromString("/usr/bin"); d->applicationLauncher.start(runnable, ProjectExplorer::DeviceKitAspect::device(target()->kit())); diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index 75c18dfeb7..7a6449fa2c 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -334,7 +334,7 @@ void CorePlugin::addToPathChooserContextMenu(Utils::PathChooser *pathChooser, QM if (pathChooser->openTerminalHandler()) pathChooser->openTerminalHandler()(); else - FileUtils::openTerminal(pathChooser->filePath().toString()); + FileUtils::openTerminal(pathChooser->filePath()); }); menu->insertAction(firstAction, showInTerminal); diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 4a81bdc061..219d1ccd02 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -2573,7 +2573,7 @@ void EditorManagerPrivate::openTerminal() { if (!d->m_contextMenuEntry || d->m_contextMenuEntry->fileName().isEmpty()) return; - FileUtils::openTerminal(d->m_contextMenuEntry->fileName().parentDir().toString()); + FileUtils::openTerminal(d->m_contextMenuEntry->fileName().parentDir()); } void EditorManagerPrivate::findInDirectory() diff --git a/src/plugins/coreplugin/fileutils.cpp b/src/plugins/coreplugin/fileutils.cpp index 04c0ffd93b..e777623f52 100644 --- a/src/plugins/coreplugin/fileutils.cpp +++ b/src/plugins/coreplugin/fileutils.cpp @@ -124,14 +124,14 @@ void FileUtils::showInGraphicalShell(QWidget *parent, const QString &pathIn) } } -void FileUtils::openTerminal(const QString &path) +void FileUtils::openTerminal(const FilePath &path) { openTerminal(path, Environment::systemEnvironment()); } -void FileUtils::openTerminal(const QString &path, const Environment &env) +void FileUtils::openTerminal(const FilePath &path, const Environment &env) { - const QFileInfo fileInfo(path); + const QFileInfo fileInfo = path.toFileInfo(); const QString pwd = QDir::toNativeSeparators(fileInfo.isDir() ? fileInfo.absoluteFilePath() : fileInfo.absolutePath()); diff --git a/src/plugins/coreplugin/fileutils.h b/src/plugins/coreplugin/fileutils.h index dd140f5d8d..ab4c2e9c21 100644 --- a/src/plugins/coreplugin/fileutils.h +++ b/src/plugins/coreplugin/fileutils.h @@ -43,8 +43,8 @@ struct CORE_EXPORT FileUtils { // Helpers for common directory browser options. static void showInGraphicalShell(QWidget *parent, const QString &path); - static void openTerminal(const QString &path); - static void openTerminal(const QString &path, const Utils::Environment &env); + static void openTerminal(const Utils::FilePath &path); + static void openTerminal(const Utils::FilePath &path, const Utils::Environment &env); static QString msgFindInDirectory(); // Platform-dependent action descriptions static QString msgGraphicalShellAction(); diff --git a/src/plugins/debugger/analyzer/startremotedialog.cpp b/src/plugins/debugger/analyzer/startremotedialog.cpp index 29d50c45e4..21024fe1a2 100644 --- a/src/plugins/debugger/analyzer/startremotedialog.cpp +++ b/src/plugins/debugger/analyzer/startremotedialog.cpp @@ -132,9 +132,9 @@ Runnable StartRemoteDialog::runnable() const Kit *kit = d->kitChooser->currentKit(); Runnable r; r.device = DeviceKitAspect::device(kit); - r.executable = Utils::FilePath::fromString(d->executable->text()); + r.executable = FilePath::fromString(d->executable->text()); r.commandLineArguments = d->arguments->text(); - r.workingDirectory = d->workingDirectory->text(); + r.workingDirectory = FilePath::fromString(d->workingDirectory->text()); return r; } diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index f00aca5572..00eec18dc0 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -176,7 +176,7 @@ void StartApplicationParameters::toSettings(QSettings *settings) const settings->setValue("LastServerAddress", serverAddress); settings->setValue("LastExternalExecutable", runnable.executable.toVariant()); settings->setValue("LastExternalExecutableArguments", runnable.commandLineArguments); - settings->setValue("LastExternalWorkingDirectory", runnable.workingDirectory); + settings->setValue("LastExternalWorkingDirectory", runnable.workingDirectory.toVariant()); settings->setValue("LastExternalBreakAtMain", breakAtMain); settings->setValue("LastExternalRunInTerminal", runInTerminal); settings->setValue("LastExternalUseTargetExtended", useTargetExtendedRemote); @@ -193,7 +193,7 @@ void StartApplicationParameters::fromSettings(const QSettings *settings) serverAddress = settings->value("LastServerAddress").toString(); runnable.executable = FilePath::fromVariant(settings->value("LastExternalExecutable")); runnable.commandLineArguments = settings->value("LastExternalExecutableArguments").toString(); - runnable.workingDirectory = settings->value("LastExternalWorkingDirectory").toString(); + runnable.workingDirectory = FilePath::fromVariant(settings->value("LastExternalWorkingDirectory")); breakAtMain = settings->value("LastExternalBreakAtMain").toBool(); runInTerminal = settings->value("LastExternalRunInTerminal").toBool(); useTargetExtendedRemote = settings->value("LastExternalUseTargetExtended").toBool(); @@ -490,7 +490,7 @@ StartApplicationParameters StartApplicationDialog::parameters() const result.kitId = d->kitChooser->currentKitId(); result.debugInfoLocation = d->debuginfoPathChooser->filePath().toString(); result.runnable.commandLineArguments = d->arguments->text(); - result.runnable.workingDirectory = d->workingDirectory->filePath().toString(); + result.runnable.workingDirectory = d->workingDirectory->filePath(); result.breakAtMain = d->breakAtMainCheckBox->isChecked(); result.runInTerminal = d->runInTerminalCheckBox->isChecked(); result.useTargetExtendedRemote = d->useTargetExtendedRemoteCheckBox->isChecked(); @@ -508,7 +508,7 @@ void StartApplicationDialog::setParameters(const StartApplicationParameters &p) d->serverResetCommandsTextEdit->setPlainText(p.serverResetCommands); d->debuginfoPathChooser->setPath(p.debugInfoLocation); d->arguments->setText(p.runnable.commandLineArguments); - d->workingDirectory->setPath(p.runnable.workingDirectory); + d->workingDirectory->setFilePath(p.runnable.workingDirectory); d->breakAtMainCheckBox->setChecked(p.breakAtMain); d->runInTerminalCheckBox->setChecked(p.runInTerminal); d->useTargetExtendedRemoteCheckBox->setChecked(p.useTargetExtendedRemote); diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index f9ef4ead62..2d1d82489b 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -2627,8 +2627,7 @@ QString DebuggerEngine::formatStartParameters() const str << " [terminal]"; str << '\n'; if (!sp.inferior.workingDirectory.isEmpty()) - str << "Directory: " << QDir::toNativeSeparators(sp.inferior.workingDirectory) - << '\n'; + str << "Directory: " << sp.inferior.workingDirectory.toUserOutput() << '\n'; } if (!sp.debugger.executable.isEmpty()) str << "Debugger: " << sp.debugger.executable.toUserOutput() << '\n'; diff --git a/src/plugins/debugger/debuggerkitinformation.cpp b/src/plugins/debugger/debuggerkitinformation.cpp index 12a085f905..5354df0af7 100644 --- a/src/plugins/debugger/debuggerkitinformation.cpp +++ b/src/plugins/debugger/debuggerkitinformation.cpp @@ -346,7 +346,7 @@ Runnable DebuggerKitAspect::runnable(const Kit *kit) Runnable runnable; if (const DebuggerItem *item = debugger(kit)) { runnable.executable = item->command(); - runnable.workingDirectory = item->workingDirectory().toString(); + runnable.workingDirectory = item->workingDirectory(); runnable.environment = kit->runEnvironment(); runnable.environment.set("LC_NUMERIC", "C"); } diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index e3fcefe3bf..4cce8c7056 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -889,7 +889,7 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, AllowTerminal allowTerm m_runParameters.inferior = runnable(); // Normalize to work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch'...) m_runParameters.inferior.workingDirectory = - FileUtils::normalizePathName(m_runParameters.inferior.workingDirectory); + FilePath::fromString(FileUtils::normalizePathName(m_runParameters.inferior.workingDirectory.toString())); setUseTerminal(allowTerminal == DoAllowTerminal && m_runParameters.useTerminal); const QByteArray envBinary = qgetenv("QTC_DEBUGGER_PATH"); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 929ec2ccdf..f5de9c91dc 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -3848,7 +3848,7 @@ void GdbEngine::setupEngine() showMessage("STARTING " + gdbCommand.toUserOutput()); m_gdbProc.setCommand(gdbCommand); - if (QFileInfo(rp.debugger.workingDirectory).isDir()) + if (rp.debugger.workingDirectory.isDir()) m_gdbProc.setWorkingDirectory(rp.debugger.workingDirectory); m_gdbProc.setEnvironment(gdbEnv); m_gdbProc.setKeepWriteChannelOpen(); @@ -4463,7 +4463,7 @@ void GdbEngine::setupInferior() setEnvironmentVariables(); if (!rp.inferior.workingDirectory.isEmpty()) - runCommand({"cd " + rp.inferior.workingDirectory}); + runCommand({"cd " + rp.inferior.workingDirectory.path()}); if (!rp.inferior.commandLineArguments.isEmpty()) { QString args = rp.inferior.commandLineArguments; runCommand({"-exec-arguments " + args}); diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 7b05e6f9ef..232be2161c 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -213,7 +213,7 @@ void LldbEngine::setupEngine() Environment environment = runParameters().debugger.environment; environment.appendOrSet("PYTHONUNBUFFERED", "1"); // avoid flushing problem on macOS m_lldbProc.setEnvironment(environment); - if (QFileInfo(runParameters().debugger.workingDirectory).isDir()) + if (runParameters().debugger.workingDirectory.isDir()) m_lldbProc.setWorkingDirectory(runParameters().debugger.workingDirectory); if (HostOsInfo::isRunningUnderRosetta()) diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index d2c68c942b..620c37fb31 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -134,7 +134,7 @@ void PdbEngine::setupEngine() } QStringList args = {bridge, scriptFile.fileName()}; - args.append(Utils::ProcessArgs::splitArgs(runParameters().inferior.workingDirectory)); + args.append(Utils::ProcessArgs::splitArgs(runParameters().inferior.workingDirectory.path())); showMessage("STARTING " + m_interpreter + ' ' + args.join(' ')); m_proc.setEnvironment(runParameters().debugger.environment.toStringList()); m_proc.start(m_interpreter, args); diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp index eb28a772e8..d10e74c9bd 100644 --- a/src/plugins/docker/dockerdevice.cpp +++ b/src/plugins/docker/dockerdevice.cpp @@ -481,7 +481,7 @@ DockerDevice::DockerDevice(const DockerDeviceData &data) setDisplayName(tr("Docker Image \"%1\" (%2)").arg(data.repo).arg(data.imageId)); setAllowEmptyCommand(true); - setOpenTerminal([this](const Environment &env, const QString &workingDir) { + setOpenTerminal([this](const Environment &env, const FilePath &workingDir) { DeviceProcess * const proc = createProcess(nullptr); QObject::connect(proc, &DeviceProcess::finished, [proc] { if (!proc->errorString().isEmpty()) { @@ -508,7 +508,7 @@ DockerDevice::DockerDevice(const DockerDeviceData &data) if (HostOsInfo::isAnyUnixHost()) { addDeviceAction({tr("Open Shell in Container"), [](const IDevice::Ptr &device, QWidget *) { - device->openTerminal(Environment(), QString()); + device->openTerminal(Environment(), FilePath()); }}); } } diff --git a/src/plugins/mcusupport/mcusupportrunconfiguration.cpp b/src/plugins/mcusupport/mcusupportrunconfiguration.cpp index f1e9de0daf..131aff1c65 100644 --- a/src/plugins/mcusupport/mcusupportrunconfiguration.cpp +++ b/src/plugins/mcusupport/mcusupportrunconfiguration.cpp @@ -97,9 +97,8 @@ public: runControl->runConfiguration()->aspect<StringAspect>()->value(), CommandLine::Raw); Runnable r; - r.workingDirectory = - target->activeBuildConfiguration()->buildDirectory().toUserOutput(); r.setCommandLine(cmd); + r.workingDirectory = target->activeBuildConfiguration()->buildDirectory(); r.environment = target->activeBuildConfiguration()->environment(); SimpleTargetRunner::doStart(r, {}); }); diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index 489fcf66cd..4cc2bd8c73 100644 --- a/src/plugins/projectexplorer/applicationlauncher.cpp +++ b/src/plugins/projectexplorer/applicationlauncher.cpp @@ -373,9 +373,9 @@ void ApplicationLauncherPrivate::start(const Runnable &runnable, const IDevice:: if (m_isLocal) { // Work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch' ...) - const QString fixedPath = FileUtils::normalizePathName(runnable.workingDirectory); + const QString fixedPath = FileUtils::normalizePathName(runnable.workingDirectory.toString()); m_guiProcess.setWorkingDirectory(fixedPath); - m_consoleProcess.setWorkingDirectory(fixedPath); + m_consoleProcess.setWorkingDirectory(FilePath::fromString(fixedPath)); Environment env = runnable.environment; if (m_runAsRoot) diff --git a/src/plugins/projectexplorer/buildaspects.cpp b/src/plugins/projectexplorer/buildaspects.cpp index 7b6f0836ab..d03f44d507 100644 --- a/src/plugins/projectexplorer/buildaspects.cpp +++ b/src/plugins/projectexplorer/buildaspects.cpp @@ -64,7 +64,7 @@ BuildDirectoryAspect::BuildDirectoryAspect(const BuildConfiguration *bc) : d(new return pathChooser() ? pathChooser()->defaultValidationFunction()(edit, error) : true; }); setOpenTerminalHandler([this, bc] { - Core::FileUtils::openTerminal(value(), bc->environment()); + Core::FileUtils::openTerminal(FilePath::fromString(value()), bc->environment()); }); } diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp index b59113d25f..720fab3a55 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp @@ -103,7 +103,7 @@ Runnable CustomExecutableRunConfiguration::runnable() const Runnable r; r.setCommandLine(commandLine()); r.environment = aspect<EnvironmentAspect>()->environment(); - r.workingDirectory = workingDirectory.toString(); + r.workingDirectory = workingDirectory; r.device = DeviceManager::defaultDesktopDevice(); if (!r.executable.isEmpty()) { diff --git a/src/plugins/projectexplorer/devicesupport/desktopdevice.cpp b/src/plugins/projectexplorer/devicesupport/desktopdevice.cpp index 4cecf64eab..f25b044f5d 100644 --- a/src/plugins/projectexplorer/devicesupport/desktopdevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/desktopdevice.cpp @@ -64,7 +64,7 @@ DesktopDevice::DesktopDevice() const QString portRange = QString::fromLatin1("%1-%2").arg(DESKTOP_PORT_START).arg(DESKTOP_PORT_END); setFreePorts(Utils::PortList::fromString(portRange)); - setOpenTerminal([](const Utils::Environment &env, const QString &workingDir) { + setOpenTerminal([](const Environment &env, const FilePath &workingDir) { Core::FileUtils::openTerminal(workingDir, env); }); } diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp index bd677772fb..8da8c3038c 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp @@ -186,7 +186,7 @@ bool IDevice::canOpenTerminal() const return bool(d->openTerminal); } -void IDevice::openTerminal(const Utils::Environment &env, const QString &workingDir) const +void IDevice::openTerminal(const Environment &env, const FilePath &workingDir) const { QTC_ASSERT(canOpenTerminal(), return); d->openTerminal(env, workingDir); diff --git a/src/plugins/projectexplorer/devicesupport/idevice.h b/src/plugins/projectexplorer/devicesupport/idevice.h index 39fb82efc3..300d97e896 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.h +++ b/src/plugins/projectexplorer/devicesupport/idevice.h @@ -223,7 +223,7 @@ public: void setupId(Origin origin, Utils::Id id = Utils::Id()); bool canOpenTerminal() const; - void openTerminal(const Utils::Environment &env, const QString &workingDir) const; + void openTerminal(const Utils::Environment &env, const Utils::FilePath &workingDir) const; bool isEmptyCommandAllowed() const; void setAllowEmptyCommand(bool allow); @@ -274,7 +274,7 @@ public: protected: IDevice(); - using OpenTerminal = std::function<void(const Utils::Environment &, const QString &)>; + using OpenTerminal = std::function<void(const Utils::Environment &, const Utils::FilePath &)>; void setOpenTerminal(const OpenTerminal &openTerminal); void setDisplayType(const QString &type); void setOsType(Utils::OsType osType); diff --git a/src/plugins/projectexplorer/environmentwidget.cpp b/src/plugins/projectexplorer/environmentwidget.cpp index 078eb2f2a5..d94ff7134d 100644 --- a/src/plugins/projectexplorer/environmentwidget.cpp +++ b/src/plugins/projectexplorer/environmentwidget.cpp @@ -56,6 +56,8 @@ #include <QTreeWidgetItem> #include <QVBoxLayout> +using namespace Utils; + namespace ProjectExplorer { class PathTreeWidget : public QTreeWidget @@ -320,7 +322,7 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, Type type, QWidget *additi if (d->m_openTerminalFunc) d->m_openTerminalFunc(env); else - Core::FileUtils::openTerminal(QDir::currentPath(), env); + Core::FileUtils::openTerminal(FilePath::fromString(QDir::currentPath()), env); }); connect(d->m_detailsContainer, &Utils::DetailsWidget::linkActivated, this, &EnvironmentWidget::linkActivated); diff --git a/src/plugins/projectexplorer/processparameters.cpp b/src/plugins/projectexplorer/processparameters.cpp index 7a08b1e7e5..742921c165 100644 --- a/src/plugins/projectexplorer/processparameters.cpp +++ b/src/plugins/projectexplorer/processparameters.cpp @@ -164,7 +164,7 @@ QString ProcessParameters::prettyCommand() const QString ProcessParameters::prettyArguments() const { QString margs = effectiveArguments(); - QString workDir = effectiveWorkingDirectory().toString(); + FilePath workDir = effectiveWorkingDirectory(); ProcessArgs::SplitError err; ProcessArgs args = ProcessArgs::prepareArgs(margs, &err, HostOsInfo::hostOs(), &m_environment, &workDir); diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index c44bc033dc..2eadaf954d 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -3704,7 +3704,7 @@ void ProjectExplorerPluginPrivate::openTerminalHere(const EnvironmentGetter &env if (!environment) return; - Core::FileUtils::openTerminal(currentNode->directory().toString(), environment.value()); + Core::FileUtils::openTerminal(currentNode->directory(), environment.value()); } void ProjectExplorerPluginPrivate::openTerminalHereWithRunEnv() @@ -3725,8 +3725,8 @@ void ProjectExplorerPluginPrivate::openTerminalHereWithRunEnv() if (!device) device = DeviceKitAspect::device(target->kit()); QTC_ASSERT(device && device->canOpenTerminal(), return); - const QString workingDir = device->type() == Constants::DESKTOP_DEVICE_TYPE - ? currentNode->directory().toString() : runnable.workingDirectory; + const FilePath workingDir = device->type() == Constants::DESKTOP_DEVICE_TYPE + ? currentNode->directory() : runnable.workingDirectory; device->openTerminal(runnable.environment, workingDir); } diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index e74127fced..2bd7a72f2b 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -400,7 +400,7 @@ Runnable RunConfiguration::runnable() const Runnable r; r.setCommandLine(commandLine()); if (auto workingDirectoryAspect = aspect<WorkingDirectoryAspect>()) - r.workingDirectory = workingDirectoryAspect->workingDirectory(macroExpander()).toString(); + r.workingDirectory = workingDirectoryAspect->workingDirectory(macroExpander()); if (auto environmentAspect = aspect<EnvironmentAspect>()) r.environment = environmentAspect->environment(); if (m_runnableModifier) diff --git a/src/plugins/projectexplorer/runcontrol.h b/src/plugins/projectexplorer/runcontrol.h index f0a5720dbb..7a10cb61cf 100644 --- a/src/plugins/projectexplorer/runcontrol.h +++ b/src/plugins/projectexplorer/runcontrol.h @@ -72,7 +72,7 @@ public: Utils::FilePath executable; QString commandLineArguments; - QString workingDirectory; + Utils::FilePath workingDirectory; Utils::Environment environment; IDevice::ConstPtr device; // Override the kit's device. Keep unset by default. QHash<Utils::Id, QVariant> extraData; diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index d476bbf5bf..043802e336 100644 --- a/src/plugins/python/pythonutils.cpp +++ b/src/plugins/python/pythonutils.cpp @@ -517,10 +517,10 @@ void openPythonRepl(const FilePath &file, ReplType type) static const auto workingDir = [](const FilePath &file) { if (file.isEmpty()) { if (ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject()) - return project->projectDirectory().toFileInfo().filePath(); - return QDir::currentPath(); + return project->projectDirectory(); + return FilePath::fromString(QDir::currentPath()); } - return file.toFileInfo().path(); + return file; }; const auto args = QStringList{"-i"} + replImportArgs(file, type); diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index c9929d0158..3701a84567 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -138,7 +138,7 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id) setRunnableModifier([this](Runnable &r) { const QmlBuildSystem *bs = static_cast<QmlBuildSystem *>(activeBuildSystem()); - r.workingDirectory = bs->targetDirectory().toString(); + r.workingDirectory = bs->targetDirectory(); }); setDisplayName(tr("QML Utility", "QMLRunConfiguration display name.")); diff --git a/src/plugins/qnx/qnxdeviceprocess.cpp b/src/plugins/qnx/qnxdeviceprocess.cpp index 42dd90cd7e..14d800e94c 100644 --- a/src/plugins/qnx/qnxdeviceprocess.cpp +++ b/src/plugins/qnx/qnxdeviceprocess.cpp @@ -55,7 +55,8 @@ QString QnxDeviceProcess::fullCommandLine(const Runnable &runnable) const "test -f $HOME/profile && . $HOME/profile ; "; if (!runnable.workingDirectory.isEmpty()) - fullCommandLine += QString::fromLatin1("cd %1 ; ").arg(ProcessArgs::quoteArg(runnable.workingDirectory)); + fullCommandLine += QString::fromLatin1("cd %1 ; ").arg( + ProcessArgs::quoteArg(runnable.workingDirectory.toString())); const Environment env = runnable.environment; for (auto it = env.constBegin(); it != env.constEnd(); ++it) { diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp index 1b70bdd6cc..e9aa58ed66 100644 --- a/src/plugins/remotelinux/linuxdevice.cpp +++ b/src/plugins/remotelinux/linuxdevice.cpp @@ -189,7 +189,7 @@ LinuxDevice::LinuxDevice() } }}); - setOpenTerminal([this](const Utils::Environment &env, const QString &workingDir) { + setOpenTerminal([this](const Environment &env, const FilePath &workingDir) { DeviceProcess * const proc = createProcess(nullptr); QObject::connect(proc, &DeviceProcess::finished, [proc] { if (!proc->errorString().isEmpty()) { @@ -218,7 +218,7 @@ LinuxDevice::LinuxDevice() if (Utils::HostOsInfo::isAnyUnixHost()) { addDeviceAction({tr("Open Remote Shell"), [](const IDevice::Ptr &device, QWidget *) { - device->openTerminal(Utils::Environment(), QString()); + device->openTerminal(Environment(), FilePath()); }}); } } diff --git a/src/plugins/remotelinux/linuxdeviceprocess.cpp b/src/plugins/remotelinux/linuxdeviceprocess.cpp index ad7f69f4a5..f46357a2ac 100644 --- a/src/plugins/remotelinux/linuxdeviceprocess.cpp +++ b/src/plugins/remotelinux/linuxdeviceprocess.cpp @@ -96,7 +96,7 @@ QString LinuxDeviceProcess::fullCommandLine(const Runnable &runnable) const } if (!runnable.workingDirectory.isEmpty()) { - cmd.addArgs({"cd", runnable.workingDirectory}); + cmd.addArgs({"cd", runnable.workingDirectory.path()}); cmd.addArgs("&&", CommandLine::Raw); } diff --git a/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp b/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp index de913de5c4..0aab43c44a 100644 --- a/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp +++ b/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp @@ -41,6 +41,7 @@ using namespace ProjectExplorer; using namespace RemoteLinux::Internal; +using namespace Utils; namespace { const QString FetchEnvButtonText @@ -79,7 +80,7 @@ RemoteLinuxEnvironmentAspectWidget::RemoteLinuxEnvironmentAspectWidget } const auto linuxDevice = device.dynamicCast<const LinuxDevice>(); QTC_ASSERT(linuxDevice, return); - linuxDevice->openTerminal(env, QString()); + linuxDevice->openTerminal(env, FilePath()); }; envWidget()->setOpenTerminalFunc(openTerminalFunc); } diff --git a/src/plugins/valgrind/callgrind/callgrindcontroller.cpp b/src/plugins/valgrind/callgrind/callgrindcontroller.cpp index f195d2e374..ffcca330cf 100644 --- a/src/plugins/valgrind/callgrind/callgrindcontroller.cpp +++ b/src/plugins/valgrind/callgrind/callgrindcontroller.cpp @@ -207,7 +207,7 @@ void CallgrindController::getLocalDataFile() { // we look for callgrind.out.PID, but there may be updated ones called ~.PID.NUM const QString baseFileName = QString("callgrind.out.%1").arg(m_pid); - const QString workingDir = m_valgrindRunnable.workingDirectory; + const QString workingDir = m_valgrindRunnable.workingDirectory.toString(); // first, set the to-be-parsed file to callgrind.out.PID QString fileName = workingDir.isEmpty() ? baseFileName : (workingDir + '/' + baseFileName); diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index 6b105111b5..6898afda66 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -752,7 +752,7 @@ void MemcheckToolPrivate::heobAction() } QString executable = sr.executable.toString(); - const QString workingDirectory = Utils::FileUtils::normalizePathName(sr.workingDirectory); + const QString workingDirectory = Utils::FileUtils::normalizePathName(sr.workingDirectory.toString()); const QString commandLineArguments = sr.commandLineArguments; const QStringList envStrings = sr.environment.toStringList(); |