diff options
author | hjk <hjk@qt.io> | 2021-08-17 13:16:44 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2021-08-17 11:43:55 +0000 |
commit | 31742185351e490e94e01d1516bc60498c3260f0 (patch) | |
tree | 2754091c74bd8d6dace313d18ee68872e39d60aa /src/plugins/perforce | |
parent | 2663af4c749ef73faf3da0b470878c00dc23ed56 (diff) | |
download | qt-creator-31742185351e490e94e01d1516bc60498c3260f0.tar.gz |
Perforce: Proliferate FilePath a bit
Change-Id: Ic3f03de192f782e59bd5c57654a45268c14f3f38
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins/perforce')
-rw-r--r-- | src/plugins/perforce/perforcechecker.cpp | 16 | ||||
-rw-r--r-- | src/plugins/perforce/perforcechecker.h | 9 | ||||
-rw-r--r-- | src/plugins/perforce/perforceplugin.cpp | 16 | ||||
-rw-r--r-- | src/plugins/perforce/perforcesettings.cpp | 2 |
4 files changed, 22 insertions, 21 deletions
diff --git a/src/plugins/perforce/perforcechecker.cpp b/src/plugins/perforce/perforcechecker.cpp index 373350fabe..bebb86768d 100644 --- a/src/plugins/perforce/perforcechecker.cpp +++ b/src/plugins/perforce/perforcechecker.cpp @@ -70,7 +70,7 @@ void PerforceChecker::resetOverrideCursor() } } -void PerforceChecker::start(const QString &binary, const QString &workingDirectory, +void PerforceChecker::start(const FilePath &binary, const FilePath &workingDirectory, const QStringList &basicArgs, int timeoutMS) { @@ -89,7 +89,7 @@ void PerforceChecker::start(const QString &binary, const QString &workingDirecto if (!workingDirectory.isEmpty()) m_process.setWorkingDirectory(workingDirectory); - m_process.setCommand({FilePath::fromString(m_binary), args}); + m_process.setCommand({m_binary, args}); m_process.start(); // Timeout handling m_timeOutMS = timeoutMS; @@ -109,7 +109,7 @@ void PerforceChecker::slotTimeOut() return; m_timedOut = true; m_process.stopProcess(); - emitFailed(tr("\"%1\" timed out after %2 ms.").arg(m_binary).arg(m_timeOutMS)); + emitFailed(tr("\"%1\" timed out after %2 ms.").arg(m_binary.toUserOutput()).arg(m_timeOutMS)); } void PerforceChecker::slotError(QProcess::ProcessError error) @@ -119,7 +119,7 @@ void PerforceChecker::slotError(QProcess::ProcessError error) switch (error) { case QProcess::FailedToStart: emitFailed(tr("Unable to launch \"%1\": %2"). - arg(QDir::toNativeSeparators(m_binary), m_process.errorString())); + arg(m_binary.toUserOutput(), m_process.errorString())); break; case QProcess::Crashed: // Handled elsewhere case QProcess::Timedout: @@ -138,15 +138,15 @@ void PerforceChecker::slotFinished() return; switch (m_process.exitStatus()) { case QProcess::CrashExit: - emitFailed(tr("\"%1\" crashed.").arg(QDir::toNativeSeparators(m_binary))); + emitFailed(tr("\"%1\" crashed.").arg(m_binary.toUserOutput())); break; case QProcess::NormalExit: if (m_process.exitCode()) { - const QString stdErr = QString::fromLocal8Bit(m_process.readAllStandardError()); + const QString stdErr = m_process.stdErr(); emitFailed(tr("\"%1\" terminated with exit code %2: %3"). - arg(QDir::toNativeSeparators(m_binary)).arg(m_process.exitCode()).arg(stdErr)); + arg(m_binary.toUserOutput()).arg(m_process.exitCode()).arg(stdErr)); } else { - parseOutput(QString::fromLocal8Bit(m_process.readAllStandardOutput())); + parseOutput(m_process.stdOut()); } break; } diff --git a/src/plugins/perforce/perforcechecker.h b/src/plugins/perforce/perforcechecker.h index 6c78e1ee84..6d8dd09146 100644 --- a/src/plugins/perforce/perforcechecker.h +++ b/src/plugins/perforce/perforcechecker.h @@ -25,6 +25,7 @@ #pragma once +#include <utils/filepath.h> #include <utils/qtcprocess.h> namespace Perforce { @@ -41,9 +42,9 @@ public: explicit PerforceChecker(QObject *parent = nullptr); ~PerforceChecker() override; - void start(const QString &binary, - const QString &workingDirectory, - const QStringList &basicArgs = QStringList(), + void start(const Utils::FilePath &binary, + const Utils::FilePath &workingDirectory, + const QStringList &basicArgs = {}, int timeoutMS = -1); bool isRunning() const; @@ -68,7 +69,7 @@ private: inline void resetOverrideCursor(); Utils::QtcProcess m_process; - QString m_binary; + Utils::FilePath m_binary; int m_timeOutMS = -1; bool m_timedOut = false; bool m_useOverideCursor = false; diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index d393214a43..081170e8df 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -239,7 +239,7 @@ public: IEditor *openPerforceSubmitEditor(const QString &fileName, const QStringList &depotFileNames); - void getTopLevel(const QString &workingDirectory = QString(), bool isSync = false); + void getTopLevel(const FilePath &workingDirectory = {}, bool isSync = false); void updateActions(ActionState) override; bool submitEditorAboutToClose() override; @@ -284,7 +284,7 @@ public: FilePath m_topLevel; }; - typedef QHash<QString, DirectoryCacheEntry> ManagedDirectoryCache; + typedef QHash<FilePath, DirectoryCacheEntry> ManagedDirectoryCache; IEditor *showOutputInEditor(const QString &title, const QString &output, Id id, const QString &source, @@ -326,7 +326,7 @@ public: void updateCheckout(const FilePath &workingDir = {}, const QStringList &dirs = {}); bool revertProject(const FilePath &workingDir, const QStringList &args, bool unchangedOnly); - bool managesDirectoryFstat(const QString &directory); + bool managesDirectoryFstat(const FilePath &directory); void applySettings(); @@ -976,7 +976,7 @@ void PerforcePluginPrivate::updateActions(VcsBasePluginPrivate::ActionState as) bool PerforcePluginPrivate::managesDirectory(const FilePath &directory, FilePath *topLevel /* = 0 */) const { - const bool rc = const_cast<PerforcePluginPrivate *>(this)->managesDirectoryFstat(directory.toString()); + const bool rc = const_cast<PerforcePluginPrivate *>(this)->managesDirectoryFstat(directory); if (topLevel) { if (rc) *topLevel = m_settings.topLevelSymLinkTarget(); @@ -994,7 +994,7 @@ bool PerforcePluginPrivate::managesFile(const FilePath &workingDirectory, const return result.stdOut.contains(QLatin1String("depotFile")); } -bool PerforcePluginPrivate::managesDirectoryFstat(const QString &directory) +bool PerforcePluginPrivate::managesDirectoryFstat(const FilePath &directory) { // Cached? const ManagedDirectoryCache::const_iterator cit = m_managedDirectoryCache.constFind(directory); @@ -1014,7 +1014,7 @@ bool PerforcePluginPrivate::managesDirectoryFstat(const QString &directory) bool managed = false; do { // Quick check: Must be at or below top level and not "../../other_path" - const QString relativeDirArgs = m_settings.relativeToTopLevelArguments(directory); + const QString relativeDirArgs = m_settings.relativeToTopLevelArguments(directory.toString()); if (!relativeDirArgs.isEmpty() && relativeDirArgs.startsWith(QLatin1String(".."))) { if (!m_settings.defaultEnv()) break; @@ -1708,7 +1708,7 @@ void PerforcePluginPrivate::slotTopLevelFailed(const QString &errorMessage) VcsOutputWindow::appendSilently(tr("Perforce: Unable to determine the repository: %1").arg(errorMessage)); } -void PerforcePluginPrivate::getTopLevel(const QString &workingDirectory, bool isSync) +void PerforcePluginPrivate::getTopLevel(const FilePath &workingDirectory, bool isSync) { // Run a new checker if (m_settings.p4BinaryPath.value().isEmpty()) @@ -1719,7 +1719,7 @@ void PerforcePluginPrivate::getTopLevel(const QString &workingDirectory, bool is connect(checker, &PerforceChecker::succeeded, dd, &PerforcePluginPrivate::setTopLevel); connect(checker, &PerforceChecker::succeeded,checker, &QObject::deleteLater); - checker->start(m_settings.p4BinaryPath.value(), workingDirectory, + checker->start(m_settings.p4BinaryPath.filePath(), workingDirectory, m_settings.commonP4Arguments(QString()), 30000); if (isSync) diff --git a/src/plugins/perforce/perforcesettings.cpp b/src/plugins/perforce/perforcesettings.cpp index a8a94899b9..614fc07ad2 100644 --- a/src/plugins/perforce/perforcesettings.cpp +++ b/src/plugins/perforce/perforcesettings.cpp @@ -262,7 +262,7 @@ PerforceSettingsPage::PerforceSettingsPage(PerforceSettings *settings) errorLabel->setStyleSheet(QString()); errorLabel->setText(PerforceSettings::tr("Testing...")); - checker->start(settings->p4BinaryPath.value(), QString(), settings->commonP4Arguments(), 10000); + checker->start(settings->p4BinaryPath.filePath(), {}, settings->commonP4Arguments(), 10000); }); Group config { |