diff options
42 files changed, 124 insertions, 87 deletions
diff --git a/src/libs/solutions/tasking/tasktree.cpp b/src/libs/solutions/tasking/tasktree.cpp index 88f804ac293..a489bc31593 100644 --- a/src/libs/solutions/tasking/tasktree.cpp +++ b/src/libs/solutions/tasking/tasktree.cpp @@ -3213,7 +3213,7 @@ static int scheduleTimeout(milliseconds timeout, QObject *context, const Timeout TimeoutTaskAdapter::TimeoutTaskAdapter() { - *task() = std::chrono::milliseconds::zero(); + *task() = milliseconds::zero(); } TimeoutTaskAdapter::~TimeoutTaskAdapter() diff --git a/src/libs/solutions/terminal/terminalview.cpp b/src/libs/solutions/terminal/terminalview.cpp index 860c7df2b6a..08a85d4f119 100644 --- a/src/libs/solutions/terminal/terminalview.cpp +++ b/src/libs/solutions/terminal/terminalview.cpp @@ -33,10 +33,11 @@ Q_LOGGING_CATEGORY(paintLog, "qtc.terminal.paint", QtWarningMsg) namespace TerminalSolution { +using namespace std::chrono; using namespace std::chrono_literals; // Minimum time between two refreshes. (30fps) -static constexpr std::chrono::milliseconds minRefreshInterval = 33ms; +static constexpr milliseconds minRefreshInterval = 33ms; class TerminalViewPrivate { @@ -77,8 +78,8 @@ public: std::array<QColor, 20> m_currentColors; - std::chrono::system_clock::time_point m_lastFlush{std::chrono::system_clock::now()}; - std::chrono::system_clock::time_point m_lastDoubleClick{std::chrono::system_clock::now()}; + system_clock::time_point m_lastFlush{system_clock::now()}; + system_clock::time_point m_lastDoubleClick{system_clock::now()}; bool m_selectLineMode{false}; Cursor m_cursor; QTimer m_cursorBlinkTimer; @@ -366,9 +367,8 @@ void TerminalView::writeToTerminal(const QByteArray &data, bool forceFlush) void TerminalView::flushVTerm(bool force) { - const std::chrono::system_clock::time_point now = std::chrono::system_clock::now(); - const std::chrono::milliseconds timeSinceLastFlush - = std::chrono::duration_cast<std::chrono::milliseconds>(now - d->m_lastFlush); + const system_clock::time_point now = system_clock::now(); + const milliseconds timeSinceLastFlush = duration_cast<milliseconds>(now - d->m_lastFlush); const bool shouldFlushImmediately = timeSinceLastFlush > minRefreshInterval; if (force || shouldFlushImmediately) { @@ -381,7 +381,7 @@ void TerminalView::flushVTerm(bool force) } if (!d->m_flushDelayTimer.isActive()) { - const std::chrono::milliseconds timeToNextFlush = (minRefreshInterval - timeSinceLastFlush); + const milliseconds timeToNextFlush = (minRefreshInterval - timeSinceLastFlush); d->m_flushDelayTimer.start(timeToNextFlush.count()); } } @@ -1078,7 +1078,7 @@ void TerminalView::mousePressEvent(QMouseEvent *event) } if (event->button() == Qt::LeftButton) { - if (d->m_selection && std::chrono::system_clock::now() - d->m_lastDoubleClick < 500ms) { + if (d->m_selection && system_clock::now() - d->m_lastDoubleClick < 500ms) { d->m_selectLineMode = true; const Selection newSelection{d->m_surface->gridToPos( {0, @@ -1139,7 +1139,7 @@ void TerminalView::mouseMoveEvent(QMouseEvent *event) d->m_scrollDirection = scrollVelocity; if (d->m_scrollTimer.isActive() && scrollVelocity != 0) { - const std::chrono::milliseconds scrollInterval = 1000ms / qAbs(scrollVelocity); + const milliseconds scrollInterval = 1000ms / qAbs(scrollVelocity); if (d->m_scrollTimer.intervalAsDuration() != scrollInterval) d->m_scrollTimer.setInterval(scrollInterval); } @@ -1209,7 +1209,7 @@ void TerminalView::mouseDoubleClickEvent(QMouseEvent *event) setSelection(Selection{hit.start, hit.end, true}); - d->m_lastDoubleClick = std::chrono::system_clock::now(); + d->m_lastDoubleClick = system_clock::now(); event->accept(); } diff --git a/src/libs/utils/pathchooser.cpp b/src/libs/utils/pathchooser.cpp index 6e563dc6aff..437b94bb5cd 100644 --- a/src/libs/utils/pathchooser.cpp +++ b/src/libs/utils/pathchooser.cpp @@ -134,7 +134,8 @@ QString BinaryVersionToolTipEventFilter::toolVersion(const CommandLine &cmd) return QString(); Process proc; proc.setCommand(cmd); - proc.runBlocking(std::chrono::seconds(1)); + using namespace std::chrono_literals; + proc.runBlocking(1s); if (proc.result() != ProcessResult::FinishedWithSuccess) return QString(); return proc.allOutput(); diff --git a/src/plugins/android/androidavdmanager.cpp b/src/plugins/android/androidavdmanager.cpp index f81fde7fd5a..25a73bcf5cb 100644 --- a/src/plugins/android/androidavdmanager.cpp +++ b/src/plugins/android/androidavdmanager.cpp @@ -222,7 +222,7 @@ static bool is32BitUserSpace() if (QSysInfo::WordSize == 32) { Process proc; proc.setCommand({"getconf", {"LONG_BIT"}}); - proc.runBlocking(std::chrono::seconds(3)); + proc.runBlocking(3s); if (proc.result() != ProcessResult::FinishedWithSuccess) return true; return proc.allOutput().trimmed() == "32"; diff --git a/src/plugins/android/androidbuildapkstep.cpp b/src/plugins/android/androidbuildapkstep.cpp index 3f22a8c2f90..107cc7844fb 100644 --- a/src/plugins/android/androidbuildapkstep.cpp +++ b/src/plugins/android/androidbuildapkstep.cpp @@ -1000,7 +1000,8 @@ QAbstractItemModel *AndroidBuildApkStep::keystoreCertificates() Process keytoolProc; keytoolProc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), params}); - keytoolProc.runBlocking(std::chrono::seconds(30), EventLoopMode::On); + using namespace std::chrono_literals; + keytoolProc.runBlocking(30s, EventLoopMode::On); if (keytoolProc.result() > ProcessResult::FinishedWithError) QMessageBox::critical(nullptr, Tr::tr("Error"), Tr::tr("Failed to run keytool.")); else diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index 043bbe2e500..40fe9b76a1e 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -599,7 +599,8 @@ QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(QString *error) const Process adbProc; CommandLine cmd{adbToolPath(), {"devices"}}; adbProc.setCommand(cmd); - adbProc.runBlocking(std::chrono::seconds(30)); + using namespace std::chrono_literals; + adbProc.runBlocking(30s); if (adbProc.result() != ProcessResult::FinishedWithSuccess) { if (error) *error = Tr::tr("Could not run: %1").arg(cmd.toUserOutput()); diff --git a/src/plugins/android/androidcreatekeystorecertificate.cpp b/src/plugins/android/androidcreatekeystorecertificate.cpp index f655ad5a3d1..ba40391610d 100644 --- a/src/plugins/android/androidcreatekeystorecertificate.cpp +++ b/src/plugins/android/androidcreatekeystorecertificate.cpp @@ -274,7 +274,8 @@ void AndroidCreateKeystoreCertificate::buttonBoxAccepted() Process genKeyCertProc; genKeyCertProc.setCommand(command); - genKeyCertProc.runBlocking(std::chrono::seconds(15), EventLoopMode::On); + using namespace std::chrono_literals; + genKeyCertProc.runBlocking(15s, EventLoopMode::On); if (genKeyCertProc.result() != ProcessResult::FinishedWithSuccess) { QMessageBox::critical(this, Tr::tr("Error"), diff --git a/src/plugins/beautifier/artisticstyle/artisticstyle.cpp b/src/plugins/beautifier/artisticstyle/artisticstyle.cpp index c3b57f0192b..489345e550e 100644 --- a/src/plugins/beautifier/artisticstyle/artisticstyle.cpp +++ b/src/plugins/beautifier/artisticstyle/artisticstyle.cpp @@ -97,7 +97,8 @@ public: { Process process; process.setCommand({command(), {"-h"}}); - process.runBlocking(std::chrono::seconds(2)); + using namespace std::chrono_literals; + process.runBlocking(2s); if (process.result() != ProcessResult::FinishedWithSuccess) return; diff --git a/src/plugins/beautifier/uncrustify/uncrustify.cpp b/src/plugins/beautifier/uncrustify/uncrustify.cpp index 5c93c96892d..4a92c7fcf02 100644 --- a/src/plugins/beautifier/uncrustify/uncrustify.cpp +++ b/src/plugins/beautifier/uncrustify/uncrustify.cpp @@ -101,7 +101,8 @@ public: { Process process; process.setCommand({command(), {"--show-config"}}); - process.runBlocking(std::chrono::seconds(2)); + using namespace std::chrono_literals; + process.runBlocking(2s); if (process.result() != ProcessResult::FinishedWithSuccess) return; diff --git a/src/plugins/clangformat/clangformatbaseindenter.cpp b/src/plugins/clangformat/clangformatbaseindenter.cpp index ee051fbcf32..5cb40cae9bf 100644 --- a/src/plugins/clangformat/clangformatbaseindenter.cpp +++ b/src/plugins/clangformat/clangformatbaseindenter.cpp @@ -29,6 +29,9 @@ using namespace TextEditor; using namespace Utils; +using namespace std::chrono; +using namespace std::chrono_literals; + namespace ClangFormat { enum class ReplacementsToKeep { OnlyIndent, IndentAndBefore, All }; @@ -525,7 +528,7 @@ public: struct CachedStyle { clang::format::FormatStyle style = clang::format::getNoStyle(); QDateTime expirationTime; - void setCache(clang::format::FormatStyle newStyle, std::chrono::milliseconds timeout) + void setCache(clang::format::FormatStyle newStyle, milliseconds timeout) { style = newStyle; expirationTime = QDateTime::currentDateTime().addMSecs(timeout.count()); @@ -851,12 +854,11 @@ clang::format::FormatStyle ClangFormatBaseIndenterPrivate::customSettingsStyle( return currentSettingsStyle; } -static std::chrono::milliseconds getCacheTimeout() +static milliseconds getCacheTimeout() { - using namespace std::chrono_literals; bool ok = false; const int envCacheTimeout = qEnvironmentVariableIntValue("CLANG_FORMAT_CACHE_TIMEOUT", &ok); - return ok ? std::chrono::milliseconds(envCacheTimeout) : 1s; + return ok ? milliseconds(envCacheTimeout) : 1s; } const clang::format::FormatStyle &ClangFormatBaseIndenter::styleForFile() const @@ -866,8 +868,7 @@ const clang::format::FormatStyle &ClangFormatBaseIndenter::styleForFile() const const clang::format::FormatStyle &ClangFormatBaseIndenterPrivate::styleForFile() const { - using namespace std::chrono_literals; - static const std::chrono::milliseconds cacheTimeout = getCacheTimeout(); + static const milliseconds cacheTimeout = getCacheTimeout(); QDateTime time = QDateTime::currentDateTime(); if (m_cachedStyle.expirationTime > time && !(m_cachedStyle.style == clang::format::getNoStyle())) diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp index f3c9542d980..336fbbbffc9 100644 --- a/src/plugins/clearcase/clearcaseplugin.cpp +++ b/src/plugins/clearcase/clearcaseplugin.cpp @@ -79,6 +79,8 @@ using namespace Core; using namespace ProjectExplorer; using namespace VcsBase; using namespace Utils; + +using namespace std::chrono; using namespace std::placeholders; namespace ClearCase::Internal { @@ -1621,7 +1623,7 @@ CommandResult ClearCasePluginPrivate::runCleartoolProc(const FilePath &workingDi process.setEnvironment(env); process.setCommand({m_settings.ccBinaryPath, arguments}); process.setWorkingDirectory(workingDir); - process.runBlocking(std::chrono::seconds(m_settings.timeOutS)); + process.runBlocking(seconds(m_settings.timeOutS)); return CommandResult(process); } @@ -2286,7 +2288,7 @@ QString ClearCasePluginPrivate::runExtDiff(const FilePath &workingDir, const QSt process.setWorkingDirectory(workingDir); process.setCodec(outputCodec ? outputCodec : QTextCodec::codecForName("UTF-8")); process.setCommand(diff); - process.runBlocking(std::chrono::seconds(timeOutS), EventLoopMode::On); + process.runBlocking(seconds(timeOutS), EventLoopMode::On); if (process.result() != ProcessResult::FinishedWithSuccess) return {}; return process.allOutput(); diff --git a/src/plugins/coreplugin/locator/javascriptfilter.cpp b/src/plugins/coreplugin/locator/javascriptfilter.cpp index a991e201692..c63271bb8df 100644 --- a/src/plugins/coreplugin/locator/javascriptfilter.cpp +++ b/src/plugins/coreplugin/locator/javascriptfilter.cpp @@ -23,6 +23,7 @@ using namespace Core::Internal; using namespace Tasking; using namespace Utils; +using namespace std::chrono; using namespace std::chrono_literals; static const char s_initData[] = R"( @@ -291,7 +292,7 @@ public: QTC_ASSERT(!isRunning(), return); m_input.m_input = input; } - void setTimeout(std::chrono::milliseconds timeout) { + void setTimeout(milliseconds timeout) { QTC_ASSERT(!isRunning(), return); m_timeout = timeout; } @@ -333,7 +334,7 @@ signals: private: QPointer<JavaScriptEngine> m_engine; JavaScriptInput m_input; - std::chrono::milliseconds m_timeout = 1000ms; + milliseconds m_timeout = 1000ms; std::unique_ptr<QTimer> m_timer; diff --git a/src/plugins/coreplugin/locator/locator.cpp b/src/plugins/coreplugin/locator/locator.cpp index fbe023d3095..95b8dc5be8f 100644 --- a/src/plugins/coreplugin/locator/locator.cpp +++ b/src/plugins/coreplugin/locator/locator.cpp @@ -38,6 +38,8 @@ using namespace Tasking; using namespace Utils; +using namespace std::chrono; + namespace Core { namespace Internal { @@ -163,7 +165,7 @@ void Locator::loadSettings() : QString("QuickOpen"); const Settings def; DB::beginGroup(settingsGroup); - m_refreshTimer.setInterval(std::chrono::minutes(DB::value("RefreshInterval", 60).toInt())); + m_refreshTimer.setInterval(minutes(DB::value("RefreshInterval", 60).toInt())); m_settings.useCenteredPopup = DB::value(kUseCenteredPopup, def.useCenteredPopup).toBool(); for (ILocatorFilter *filter : std::as_const(m_filters)) { @@ -359,7 +361,7 @@ void Locator::setRefreshInterval(int interval) m_refreshTimer.setInterval(0); return; } - m_refreshTimer.setInterval(std::chrono::minutes(interval)); + m_refreshTimer.setInterval(minutes(interval)); m_refreshTimer.start(); } diff --git a/src/plugins/coreplugin/plugininstallwizard.cpp b/src/plugins/coreplugin/plugininstallwizard.cpp index 3963ca0d126..5b342bf6c6a 100644 --- a/src/plugins/coreplugin/plugininstallwizard.cpp +++ b/src/plugins/coreplugin/plugininstallwizard.cpp @@ -366,7 +366,8 @@ static std::function<void(FilePath)> postCopyOperation() // to get it loaded as a plugin in Qt Creator. Process xattr; xattr.setCommand({"/usr/bin/xattr", {"-d", "com.apple.quarantine", filePath.absoluteFilePath().toString()}}); - xattr.runBlocking(std::chrono::seconds(1)); + using namespace std::chrono_literals; + xattr.runBlocking(1s); }; } diff --git a/src/plugins/coreplugin/progressmanager/processprogress.cpp b/src/plugins/coreplugin/progressmanager/processprogress.cpp index c529bb7329e..e9348fce41d 100644 --- a/src/plugins/coreplugin/progressmanager/processprogress.cpp +++ b/src/plugins/coreplugin/progressmanager/processprogress.cpp @@ -14,6 +14,7 @@ using namespace Utils; +using namespace std::chrono; using namespace std::chrono_literals; namespace Core { @@ -34,7 +35,7 @@ public: QPointer<FutureProgress> m_futureProgress; QString m_displayName; FutureProgress::KeepOnFinishType m_keep = FutureProgress::HideOnFinish; - std::chrono::seconds m_expectedDuration = 2s; + seconds m_expectedDuration = 2s; }; ProcessProgressPrivate::ProcessProgressPrivate(ProcessProgress *progress, Process *process) @@ -150,7 +151,7 @@ void ProcessProgress::setProgressParser(const ProgressParser &parser) d.get(), &ProcessProgressPrivate::parseProgress); } -void ProcessProgress::setExpectedDuration(std::chrono::seconds duration) +void ProcessProgress::setExpectedDuration(seconds duration) { d->m_expectedDuration = qMin(1s, duration); } diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.cpp b/src/plugins/coreplugin/progressmanager/progressmanager.cpp index ad5e73ef20c..57239c2127f 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager.cpp +++ b/src/plugins/coreplugin/progressmanager/progressmanager.cpp @@ -34,13 +34,15 @@ #include <QTimer> #include <QVariant> +using namespace Core::Internal; +using namespace Utils; + +using namespace std::chrono; + static const char kSettingsGroup[] = "Progress"; static const char kDetailsPinned[] = "DetailsPinned"; static const bool kDetailsPinnedDefault = true; -static const std::chrono::milliseconds TimerInterval{100}; - -using namespace Core::Internal; -using namespace Utils; +static const milliseconds TimerInterval{100}; namespace Core { @@ -48,7 +50,7 @@ class ProgressTimer : public QObject { public: ProgressTimer(const QFutureInterfaceBase &futureInterface, - std::chrono::seconds expectedDuration, + seconds expectedDuration, QObject *parent) : QObject(parent) , m_futureInterface(futureInterface) @@ -72,7 +74,7 @@ private: } QFutureInterfaceBase m_futureInterface; - std::chrono::seconds m_expectedDuration; + seconds m_expectedDuration; int m_currentTime = 0; QTimer m_timer; }; @@ -779,7 +781,7 @@ FutureProgress *ProgressManager::addTask(const QFuture<void> &future, const QStr FutureProgress *ProgressManager::addTimedTask(const QFutureInterface<void> &futureInterface, const QString &title, Id type, - std::chrono::seconds expectedDuration, + seconds expectedDuration, ProgressFlags flags) { QFutureInterface<void> dummy(futureInterface); // Need mutable to access .future() @@ -791,7 +793,7 @@ FutureProgress *ProgressManager::addTimedTask(const QFutureInterface<void> &futu FutureProgress *ProgressManager::addTimedTask(const QFuture<void> &future, const QString &title, Id type, - std::chrono::seconds expectedDuration, + seconds expectedDuration, ProgressFlags flags) { QFutureInterface<void> dummyFutureInterface; diff --git a/src/plugins/coreplugin/progressmanager/taskprogress.cpp b/src/plugins/coreplugin/progressmanager/taskprogress.cpp index b903b74dcc5..738f5a68ddc 100644 --- a/src/plugins/coreplugin/progressmanager/taskprogress.cpp +++ b/src/plugins/coreplugin/progressmanager/taskprogress.cpp @@ -18,10 +18,12 @@ using namespace Utils; using namespace Tasking; +using namespace std::chrono; + namespace Core { static const int ProgressResolution = 100; // 100 discrete values -static const std::chrono::milliseconds TimerInterval{20}; // 20 ms = 50 Hz +static const milliseconds TimerInterval{20}; // 20 ms = 50 Hz class TaskProgressPrivate : public QObject { @@ -44,7 +46,7 @@ public: QPointer<FutureProgress> m_futureProgress; Id m_id; bool m_isAutoStopOnCancel = true; - std::chrono::milliseconds m_halfLifeTimePerTask{1000}; + milliseconds m_halfLifeTimePerTask{1000}; QString m_displayName; FutureProgress::KeepOnFinishType m_keep = FutureProgress::HideOnFinish; bool m_isSubtitleVisibleInStatusBar = false; @@ -83,7 +85,7 @@ void TaskProgressPrivate::advanceProgress(int newValue) void TaskProgressPrivate::updateProgress() { - using double_millis = std::chrono::duration<double, std::milli>; + using double_millis = duration<double, std::milli>; const int halfLife = qRound(m_halfLifeTimePerTask / double_millis(TimerInterval)); const int pMin = ProgressResolution * m_currentProgress; const int pMax = ProgressResolution * (m_currentProgress + 1); @@ -149,7 +151,7 @@ void TaskProgress::setAutoStopOnCancel(bool enable) d->m_isAutoStopOnCancel = enable; } -void TaskProgress::setHalfLifeTimePerTask(std::chrono::milliseconds duration) +void TaskProgress::setHalfLifeTimePerTask(milliseconds duration) { d->m_halfLifeTimePerTask = duration; } diff --git a/src/plugins/coreplugin/terminal/searchableterminal.cpp b/src/plugins/coreplugin/terminal/searchableterminal.cpp index 5a98d3e57d4..5022be6b19c 100644 --- a/src/plugins/coreplugin/terminal/searchableterminal.cpp +++ b/src/plugins/coreplugin/terminal/searchableterminal.cpp @@ -13,11 +13,12 @@ Q_LOGGING_CATEGORY(terminalSearchLog, "qtc.terminal.search", QtWarningMsg) using namespace Utils; +using namespace std::chrono; using namespace std::chrono_literals; namespace Core { -constexpr std::chrono::milliseconds debounceInterval = 100ms; +constexpr milliseconds debounceInterval = 100ms; TerminalSearch::TerminalSearch(TerminalSolution::TerminalSurface *surface) : m_surface(surface) diff --git a/src/plugins/cppcheck/cppcheckrunner.cpp b/src/plugins/cppcheck/cppcheckrunner.cpp index 1a08b391781..cf8633c8ddf 100644 --- a/src/plugins/cppcheck/cppcheckrunner.cpp +++ b/src/plugins/cppcheck/cppcheckrunner.cpp @@ -19,7 +19,8 @@ CppcheckRunner::CppcheckRunner(CppcheckTool &tool) : m_tool(tool) Process getConf; getConf.setCommand({"getconf", {"ARG_MAX"}}); getConf.start(); - getConf.waitForFinished(std::chrono::seconds(2)); + using namespace std::chrono_literals; + getConf.waitForFinished(2s); const QByteArray argMax = getConf.rawStdOut().replace("\n", ""); m_maxArgumentsLength = std::max(argMax.toInt(), m_maxArgumentsLength); } diff --git a/src/plugins/debugger/debuggeritemmanager.cpp b/src/plugins/debugger/debuggeritemmanager.cpp index 3ee3050fa69..2644e3fa125 100644 --- a/src/plugins/debugger/debuggeritemmanager.cpp +++ b/src/plugins/debugger/debuggeritemmanager.cpp @@ -621,7 +621,8 @@ void DebuggerItemModel::autoDetectGdbOrLldbDebuggers(const FilePaths &searchPath if (searchPaths.front().osType() == OsTypeMac) { Process proc; proc.setCommand({"xcrun", {"--find", "lldb"}}); - proc.runBlocking(std::chrono::seconds(2)); + using namespace std::chrono_literals; + proc.runBlocking(2s); // FIXME: if (proc.result() == ProcessResult::FinishedWithSuccess) { QString lPath = proc.allOutput().trimmed(); diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 4560aa92bda..c9681e3e27f 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -213,7 +213,8 @@ void LldbEngine::setupEngine() void LldbEngine::handleLldbStarted() { - m_lldbProc.waitForReadyRead(std::chrono::seconds(1)); + using namespace std::chrono_literals; + m_lldbProc.waitForReadyRead(1s); showStatusMessage(Tr::tr("Setting up inferior...")); diff --git a/src/plugins/ios/iosconfigurations.cpp b/src/plugins/ios/iosconfigurations.cpp index 900351d388b..69be96f3e2a 100644 --- a/src/plugins/ios/iosconfigurations.cpp +++ b/src/plugins/ios/iosconfigurations.cpp @@ -217,7 +217,8 @@ static QByteArray decodeProvisioningProfile(const QString &path) Process p; // path is assumed to be valid file path to .mobileprovision p.setCommand({"openssl", {"smime", "-inform", "der", "-verify", "-in", path}}); - p.runBlocking(std::chrono::seconds(3)); + using namespace std::chrono_literals; + p.runBlocking(3s); if (p.result() != ProcessResult::FinishedWithSuccess) qCDebug(iosCommonLog) << "Reading signed provisioning file failed" << path; return p.cleanedStdOut().toLatin1(); diff --git a/src/plugins/ios/iosprobe.cpp b/src/plugins/ios/iosprobe.cpp index 3cb661df73d..e934ea01f91 100644 --- a/src/plugins/ios/iosprobe.cpp +++ b/src/plugins/ios/iosprobe.cpp @@ -42,7 +42,8 @@ void XcodeProbe::detectDeveloperPaths() { Utils::Process selectedXcode; selectedXcode.setCommand({"/usr/bin/xcode-select", {"--print-path"}}); - selectedXcode.runBlocking(std::chrono::seconds(5)); + using namespace std::chrono_literals; + selectedXcode.runBlocking(5s); if (selectedXcode.result() != ProcessResult::FinishedWithSuccess) qCWarning(probeLog) << QString::fromLatin1("Could not detect selected Xcode using xcode-select"); diff --git a/src/plugins/ios/iostoolhandler.cpp b/src/plugins/ios/iostoolhandler.cpp index 64acddae4ca..81da8bfef33 100644 --- a/src/plugins/ios/iostoolhandler.cpp +++ b/src/plugins/ios/iostoolhandler.cpp @@ -596,7 +596,8 @@ IosDeviceToolHandlerPrivate::IosDeviceToolHandlerPrivate(const IosDeviceType &de qCDebug(toolHandlerLog) << "IosToolHandler runEnv:" << env.toStringList(); process->setEnvironment(env); process->setProcessMode(ProcessMode::Writer); - process->setReaperTimeout(std::chrono::milliseconds(1500)); + using namespace std::chrono_literals; + process->setReaperTimeout(1500ms); QObject::connect(process.get(), &Process::readyReadStandardOutput, q, [this] { subprocessHasData(); }); diff --git a/src/plugins/mcusupport/mcusupportversiondetection.cpp b/src/plugins/mcusupport/mcusupportversiondetection.cpp index aa9b0a98991..56fe961569c 100644 --- a/src/plugins/mcusupport/mcusupportversiondetection.cpp +++ b/src/plugins/mcusupport/mcusupportversiondetection.cpp @@ -52,7 +52,8 @@ QString McuPackageExecutableVersionDetector::parseVersion(const FilePath &packag Process process; process.setCommand({binaryPath, m_detectionArgs}); process.start(); - if (!process.waitForFinished(std::chrono::seconds(3)) || process.result() != ProcessResult::FinishedWithSuccess) + using namespace std::chrono_literals; + if (!process.waitForFinished(3s) || process.result() != ProcessResult::FinishedWithSuccess) return {}; return matchRegExp(process.allOutput(), m_detectionRegExp); diff --git a/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp b/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp index 4529e57fe30..7562abbe6e5 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp @@ -93,7 +93,8 @@ static bool qDebug("In %s, running:\n%s\n", qPrintable(workingDirectory.toUserOutput()), qPrintable(cmd.toUserOutput())); process.setCommand(cmd); - process.runBlocking(std::chrono::seconds(30), EventLoopMode::On); + using namespace std::chrono_literals; + process.runBlocking(30s, EventLoopMode::On); if (process.result() != Utils::ProcessResult::FinishedWithSuccess) { *errorMessage = QString("Generator script failed: %1").arg(process.exitMessage()); const QString stdErr = process.cleanedStdErr(); diff --git a/src/plugins/projectexplorer/extracompiler.cpp b/src/plugins/projectexplorer/extracompiler.cpp index 534d9b1e0af..b48ba138aa7 100644 --- a/src/plugins/projectexplorer/extracompiler.cpp +++ b/src/plugins/projectexplorer/extracompiler.cpp @@ -390,7 +390,8 @@ void ProcessExtraCompiler::runInThread(QPromise<FileNameToContentsHash> &promise return; while (!promise.isCanceled()) { - if (process.waitForFinished(std::chrono::milliseconds(200))) + using namespace std::chrono_literals; + if (process.waitForFinished(200ms)) break; } diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp index 56811773ec9..56d535e5145 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -1325,7 +1325,8 @@ void SimpleTargetRunnerPrivate::stop() switch (m_state) { case Run: m_process.stop(); - if (!m_process.waitForFinished(std::chrono::seconds(2))) { // TODO: it may freeze on some devices + using namespace std::chrono_literals; + if (!m_process.waitForFinished(2s)) { // TODO: it may freeze on some devices q->appendMessage(Tr::tr("Remote process did not finish in time. " "Connectivity lost?"), ErrorMessageFormat); m_process.close(); diff --git a/src/plugins/python/pythonlanguageclient.cpp b/src/plugins/python/pythonlanguageclient.cpp index ab3cf170730..c4eb0290748 100644 --- a/src/plugins/python/pythonlanguageclient.cpp +++ b/src/plugins/python/pythonlanguageclient.cpp @@ -86,7 +86,8 @@ static PythonLanguageServerState checkPythonLanguageServer(const FilePath &pytho Process pythonProcess; pythonProcess.setCommand({python, {"-m", "pip", "-V"}}); - pythonProcess.runBlocking(std::chrono::seconds(2)); + using namespace std::chrono_literals; + pythonProcess.runBlocking(2s); if (pythonProcess.allOutput().startsWith("pip ")) return {PythonLanguageServerState::CanBeInstalled, lspPath}; return {PythonLanguageServerState::CanNotBeInstalled, FilePath()}; diff --git a/src/plugins/python/pythonsettings.cpp b/src/plugins/python/pythonsettings.cpp index 04a607e3ce1..cfa61b5452a 100644 --- a/src/plugins/python/pythonsettings.cpp +++ b/src/plugins/python/pythonsettings.cpp @@ -71,7 +71,8 @@ static Interpreter createInterpreter(const FilePath &python, Process pythonProcess; pythonProcess.setProcessChannelMode(QProcess::MergedChannels); pythonProcess.setCommand({python, {"--version"}}); - pythonProcess.runBlocking(std::chrono::seconds(1)); + using namespace std::chrono_literals; + pythonProcess.runBlocking(1s); if (pythonProcess.result() == ProcessResult::FinishedWithSuccess) result.name = pythonProcess.cleanedStdOut().trimmed(); if (result.name.isEmpty()) diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index d355800e0a4..2ecfe495bcd 100644 --- a/src/plugins/python/pythonutils.cpp +++ b/src/plugins/python/pythonutils.cpp @@ -149,7 +149,8 @@ QString pythonName(const FilePath &pythonPath) if (name.isEmpty()) { Process pythonProcess; pythonProcess.setCommand({pythonPath, {"--version"}}); - pythonProcess.runBlocking(std::chrono::seconds(2)); + using namespace std::chrono_literals; + pythonProcess.runBlocking(2s); if (pythonProcess.result() != ProcessResult::FinishedWithSuccess) return {}; name = pythonProcess.allOutput().trimmed(); diff --git a/src/plugins/qbsprojectmanager/qbsprofilemanager.cpp b/src/plugins/qbsprojectmanager/qbsprofilemanager.cpp index b761b726674..cf9f663bc7e 100644 --- a/src/plugins/qbsprojectmanager/qbsprofilemanager.cpp +++ b/src/plugins/qbsprojectmanager/qbsprofilemanager.cpp @@ -229,7 +229,8 @@ QString QbsProfileManager::runQbsConfig(QbsConfigOp op, const QString &key, cons Utils::Process qbsConfig; qbsConfig.setCommand({qbsConfigExe, args}); qbsConfig.start(); - if (!qbsConfig.waitForFinished(std::chrono::seconds(5))) { + using namespace std::chrono_literals; + if (!qbsConfig.waitForFinished(5s)) { Core::MessageManager::writeFlashing( Tr::tr("Failed to run qbs config: %1").arg(qbsConfig.errorString())); } else if (qbsConfig.exitCode() != 0) { diff --git a/src/plugins/qbsprojectmanager/qbssession.cpp b/src/plugins/qbsprojectmanager/qbssession.cpp index c3e397e3cfa..99c37cfd8d4 100644 --- a/src/plugins/qbsprojectmanager/qbssession.cpp +++ b/src/plugins/qbsprojectmanager/qbssession.cpp @@ -215,7 +215,8 @@ QbsSession::~QbsSession() d->qbsProcess->disconnect(this); if (d->qbsProcess->state() == QProcess::Running) { sendQuitPacket(); - d->qbsProcess->waitForFinished(std::chrono::seconds(10)); + using namespace std::chrono_literals; + d->qbsProcess->waitForFinished(10s); } delete d->qbsProcess; } diff --git a/src/plugins/qbsprojectmanager/qbssettings.cpp b/src/plugins/qbsprojectmanager/qbssettings.cpp index 9beb57c6920..79299bbb32c 100644 --- a/src/plugins/qbsprojectmanager/qbssettings.cpp +++ b/src/plugins/qbsprojectmanager/qbssettings.cpp @@ -35,7 +35,8 @@ static QString getQbsVersion(const FilePath &qbsExe) Process qbsProc; qbsProc.setCommand({qbsExe, {"--version"}}); qbsProc.start(); - if (!qbsProc.waitForFinished(std::chrono::seconds(5)) || qbsProc.exitCode() != 0) + using namespace std::chrono_literals; + if (!qbsProc.waitForFinished(5s) || qbsProc.exitCode() != 0) return {}; return QString::fromLocal8Bit(qbsProc.rawStdOut()).trimmed(); } diff --git a/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp b/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp index 5031e811bd7..2f229985960 100644 --- a/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp +++ b/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp @@ -43,6 +43,9 @@ #include <QFileSystemWatcher> #include <QQmlEngine> +using namespace std::chrono; +using namespace std::chrono_literals; + namespace QmlDesigner { namespace { @@ -75,15 +78,12 @@ class PreviewTimeStampProvider : public TimeStampProviderInterface public: Sqlite::TimeStamp timeStamp(Utils::SmallStringView) const override { - auto now = std::chrono::steady_clock::now(); - - return std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count(); + return duration_cast<seconds>(steady_clock::now().time_since_epoch()).count(); } Sqlite::TimeStamp pause() const override { - using namespace std::chrono_literals; - return std::chrono::duration_cast<std::chrono::seconds>(1h).count(); + return duration_cast<seconds>(1h).count(); } }; @@ -307,7 +307,6 @@ void QmlDesignerProjectManager::editorOpened(::Core::IEditor *) {} void QmlDesignerProjectManager::currentEditorChanged(::Core::IEditor *) { - using namespace std::chrono_literals; m_previewImageCacheData->timer.start(10s); } diff --git a/src/plugins/qnx/qnxutils.cpp b/src/plugins/qnx/qnxutils.cpp index 51ea327fa55..634800fe993 100644 --- a/src/plugins/qnx/qnxutils.cpp +++ b/src/plugins/qnx/qnxutils.cpp @@ -107,7 +107,8 @@ EnvironmentItems QnxUtils::qnxEnvironmentFromEnvFile(const FilePath &filePath) // waiting for finish QApplication::setOverrideCursor(Qt::BusyCursor); - bool waitResult = process.waitForFinished(std::chrono::seconds(10)); + using namespace std::chrono_literals; + bool waitResult = process.waitForFinished(10s); QApplication::restoreOverrideCursor(); if (!waitResult) return items; diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp index 058e1ffe29c..95de9947244 100644 --- a/src/plugins/remotelinux/linuxdevice.cpp +++ b/src/plugins/remotelinux/linuxdevice.cpp @@ -450,7 +450,8 @@ bool SshProcessInterface::runInShell(const CommandLine &command, const QByteArra process.setCommand(cmd); process.setWriteData(data); process.start(); - bool isFinished = process.waitForFinished(std::chrono::seconds(2)); // It may freeze on some devices + using namespace std::chrono_literals; + const bool isFinished = process.waitForFinished(2s); // It may freeze on some devices if (!isFinished) { Core::MessageManager::writeFlashing(tr("Can't send control signal to the %1 device. " "The device might have been disconnected.") diff --git a/src/plugins/silversearcher/findinfilessilversearcher.cpp b/src/plugins/silversearcher/findinfilessilversearcher.cpp index 68db85a2dec..a6f79ce6091 100644 --- a/src/plugins/silversearcher/findinfilessilversearcher.cpp +++ b/src/plugins/silversearcher/findinfilessilversearcher.cpp @@ -51,7 +51,8 @@ static bool isSilverSearcherAvailable() Process silverSearcherProcess; silverSearcherProcess.setCommand({"ag", {"--version"}}); silverSearcherProcess.start(); - return silverSearcherProcess.waitForFinished(std::chrono::seconds(1)) + using namespace std::chrono_literals; + return silverSearcherProcess.waitForFinished(1s) && silverSearcherProcess.cleanedStdOut().contains("ag version"); } diff --git a/src/plugins/valgrind/valgrindmemcheckparsertest.cpp b/src/plugins/valgrind/valgrindmemcheckparsertest.cpp index c13295e2a87..66824f718c3 100644 --- a/src/plugins/valgrind/valgrindmemcheckparsertest.cpp +++ b/src/plugins/valgrind/valgrindmemcheckparsertest.cpp @@ -192,7 +192,8 @@ void ValgrindMemcheckParserTest::initTest(const QString &testfile, const QString m_process->setCommand({FilePath::fromString(fakeValgrind), args + otherArgs}); m_process->start(); - QVERIFY(m_process->waitForStarted(std::chrono::seconds(5))); + using namespace std::chrono_literals; + QVERIFY(m_process->waitForStarted(5s)); QCOMPARE(m_process->state(), QProcess::Running); QVERIFY2(m_process->error() == QProcess::UnknownError, qPrintable(m_process->errorString())); QVERIFY(m_server->waitForNewConnection(5000)); diff --git a/src/plugins/vcsbase/vcscommand.cpp b/src/plugins/vcsbase/vcscommand.cpp index f4f7cbc064c..f1995b2d844 100644 --- a/src/plugins/vcsbase/vcscommand.cpp +++ b/src/plugins/vcsbase/vcscommand.cpp @@ -19,6 +19,8 @@ using namespace Core; using namespace Utils; +using namespace std::chrono; + namespace VcsBase { namespace Internal { @@ -115,7 +117,7 @@ void VcsCommandPrivate::setupProcess(Process *process, const Job &job) ProcessProgress *progress = new ProcessProgress(process); progress->setDisplayName(m_displayName); - progress->setExpectedDuration(std::chrono::seconds(qMin(1, job.timeoutS / 5))); + progress->setExpectedDuration(seconds(qMin(1, job.timeoutS / 5))); if (m_progressParser) progress->setProgressParser(m_progressParser); } @@ -307,7 +309,7 @@ CommandResult VcsCommand::runBlockingHelper(const CommandLine &command, int time const EventLoopMode eventLoopMode = d->eventLoopMode(); process.setTimeOutMessageBoxEnabled(eventLoopMode == EventLoopMode::On); - process.runBlocking(std::chrono::seconds(timeoutS), eventLoopMode); + process.runBlocking(seconds(timeoutS), eventLoopMode); d->handleDone(&process, job); return CommandResult(process); diff --git a/src/shared/qtsingleapplication/qtsingleapplication.cpp b/src/shared/qtsingleapplication/qtsingleapplication.cpp index 5b5f80ad6f5..6bfdc0edfa4 100644 --- a/src/shared/qtsingleapplication/qtsingleapplication.cpp +++ b/src/shared/qtsingleapplication/qtsingleapplication.cpp @@ -11,6 +11,8 @@ #include <QSharedMemory> #include <QWidget> +using namespace std::chrono; + namespace SharedTools { static const int instancesSize = 1024; @@ -179,12 +181,11 @@ public: : QtSingleApplication(id, argc, argv) , m_align(21, QChar::Space) {} - void setFreezeTreshold(std::chrono::milliseconds freezeAbove) { m_threshold = freezeAbove; } + void setFreezeTreshold(milliseconds freezeAbove) { m_threshold = freezeAbove; } bool notify(QObject *receiver, QEvent *event) override { if (m_inNotify) return QtSingleApplication::notify(receiver, event); - using namespace std::chrono; const auto start = system_clock::now(); const QPointer<QObject> p(receiver); const QString className = QLatin1String(receiver->metaObject()->className()); @@ -213,7 +214,7 @@ public: private: bool m_inNotify = false; const QString m_align; - std::chrono::milliseconds m_threshold{100}; + milliseconds m_threshold{100}; }; QtSingleApplication *createApplication(const QString &id, int &argc, char **argv) @@ -227,7 +228,7 @@ QtSingleApplication *createApplication(const QString &id, int &argc, char **argv qDebug() << "Change the freeze detection threshold by setting the" << s_freezeDetector << "env var to a different numeric value (in ms)."; ApplicationWithFreezerDetector *app = new ApplicationWithFreezerDetector(id, argc, argv); - app->setFreezeTreshold(std::chrono::milliseconds(*freezeDetector)); + app->setFreezeTreshold(milliseconds(*freezeDetector)); return app; } diff --git a/tests/unit/tests/utils/eventspy.cpp b/tests/unit/tests/utils/eventspy.cpp index 31cdac91a27..72df4ff5612 100644 --- a/tests/unit/tests/utils/eventspy.cpp +++ b/tests/unit/tests/utils/eventspy.cpp @@ -6,13 +6,12 @@ #include <QCoreApplication> #include <QEvent> -using namespace std::literals::chrono_literals; +using namespace std::chrono; EventSpy::EventSpy(uint eventType) - : startTime(std::chrono::steady_clock::now()), - eventType(eventType) -{ -} + : startTime(steady_clock::now()) + , eventType(eventType) +{} bool EventSpy::waitForEvent() { @@ -26,15 +25,12 @@ bool EventSpy::event(QEvent *event) { if (event->type() == eventType) { eventHappened = true; - return true; } - return false; } bool EventSpy::shouldRun() const { - return !eventHappened - && (std::chrono::steady_clock::now() - startTime) < 1s; + return !eventHappened && (steady_clock::now() - startTime) < 1s; } |