diff --git a/src/libs/utils/filepath.cpp b/src/libs/utils/filepath.cpp index ba27d03dde9..7cc99d0b803 100644 --- a/src/libs/utils/filepath.cpp +++ b/src/libs/utils/filepath.cpp @@ -822,6 +822,14 @@ FilePath FilePath::absoluteFilePath(const FilePath &tail) const return tail; } +FilePath FilePath::normalizePathName() const +{ + FilePath result = *this; + if (!needsDevice()) // FIXME: Assumes no remote Windows and Mac for now. + result.m_data = FileUtils::normalizePathName(result.m_data); + return result; +} + /// Constructs a FilePath from \a filename /// \a filename is not checked for validity. FilePath FilePath::fromString(const QString &filepath) diff --git a/src/libs/utils/filepath.h b/src/libs/utils/filepath.h index e97ee4f2708..691548fd725 100644 --- a/src/libs/utils/filepath.h +++ b/src/libs/utils/filepath.h @@ -120,6 +120,10 @@ public: FilePath absoluteFilePath() const; FilePath absoluteFilePath(const FilePath &tail) const; + // makes sure that capitalization of directories is canonical + // on Windows and macOS. This is rarely needed. + FilePath normalizePathName() const; + bool operator==(const FilePath &other) const; bool operator!=(const FilePath &other) const; bool operator<(const FilePath &other) const; diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index f152dffc094..e1ebd51f4fb 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -913,8 +913,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 = - FilePath::fromString(FileUtils::normalizePathName(m_runParameters.inferior.workingDirectory.toString())); + m_runParameters.inferior.workingDirectory = m_runParameters.inferior.workingDirectory.normalizePathName(); setUseTerminal(allowTerminal == DoAllowTerminal && m_runParameters.useTerminal); const QByteArray envBinary = qgetenv("QTC_DEBUGGER_PATH"); diff --git a/src/plugins/debugger/unstartedappwatcherdialog.cpp b/src/plugins/debugger/unstartedappwatcherdialog.cpp index 19af428adeb..6f632f1f1d7 100644 --- a/src/plugins/debugger/unstartedappwatcherdialog.cpp +++ b/src/plugins/debugger/unstartedappwatcherdialog.cpp @@ -255,7 +255,7 @@ void UnstartedAppWatcherDialog::startStopTimer(bool start) void UnstartedAppWatcherDialog::findProcess() { - const QString &appName = Utils::FileUtils::normalizePathName(m_pathChooser->filePath().toString()); + const QString &appName = m_pathChooser->filePath().normalizePathName().toString(); DeviceProcessItem fallback; foreach (const DeviceProcessItem &p, DeviceProcessList::localProcesses()) { if (Utils::FileUtils::normalizePathName(p.exe) == appName) { diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index 16c2bb3eeee..8644ec99483 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.toString()); + const FilePath fixedPath = runnable.workingDirectory.normalizePathName(); m_guiProcess.setWorkingDirectory(fixedPath); - m_consoleProcess.setWorkingDirectory(FilePath::fromString(fixedPath)); + m_consoleProcess.setWorkingDirectory(fixedPath); Environment env = runnable.environment; if (m_runAsRoot) diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index 5e334827f61..7da7d6962cd 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -148,10 +148,8 @@ QmlProject::QmlProject(const Utils::FilePath &fileName) QmlBuildSystem::QmlBuildSystem(Target *target) : BuildSystem(target) { - const QString normalized - = Utils::FileUtils::normalizePathName(target->project() - ->projectFilePath().toFileInfo().canonicalFilePath()); - m_canonicalProjectDir = Utils::FilePath::fromString(normalized).parentDir(); + m_canonicalProjectDir = + target->project()->projectFilePath().canonicalPath().normalizePathName().parentDir(); connect(target->project(), &Project::projectFileIsDirty, this, &QmlBuildSystem::refreshProjectFile); diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index 6753dc3ad84..e0de24da1be 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -449,7 +449,7 @@ void ExamplesListModel::parseTutorials(QXmlStreamReader *reader, const QString & static QString resourcePath() { // normalize paths so QML doesn't freak out if it's wrongly capitalized on Windows - return Utils::FileUtils::normalizePathName(Core::ICore::resourcePath().toString()); + return Core::ICore::resourcePath().normalizePathName().toString(); } void ExamplesListModel::updateExamples() diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index e243156d842..d12c86b5206 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -752,7 +752,7 @@ void MemcheckToolPrivate::heobAction() } FilePath executable = sr.command.executable(); - const QString workingDirectory = Utils::FileUtils::normalizePathName(sr.workingDirectory.toString()); + const QString workingDirectory = sr.workingDirectory.normalizePathName().toString(); const QString commandLineArguments = sr.command.arguments(); const QStringList envStrings = sr.environment.toStringList();