forked from qt-creator/qt-creator
Use more std::chrono and std::chrono_literals namespaces
Change-Id: Ib8c83988d7afe35d81b87ff8c5c87eef2082f12d Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -3213,7 +3213,7 @@ static int scheduleTimeout(milliseconds timeout, QObject *context, const Timeout
|
|||||||
|
|
||||||
TimeoutTaskAdapter::TimeoutTaskAdapter()
|
TimeoutTaskAdapter::TimeoutTaskAdapter()
|
||||||
{
|
{
|
||||||
*task() = std::chrono::milliseconds::zero();
|
*task() = milliseconds::zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeoutTaskAdapter::~TimeoutTaskAdapter()
|
TimeoutTaskAdapter::~TimeoutTaskAdapter()
|
||||||
|
@@ -33,10 +33,11 @@ Q_LOGGING_CATEGORY(paintLog, "qtc.terminal.paint", QtWarningMsg)
|
|||||||
|
|
||||||
namespace TerminalSolution {
|
namespace TerminalSolution {
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
// Minimum time between two refreshes. (30fps)
|
// Minimum time between two refreshes. (30fps)
|
||||||
static constexpr std::chrono::milliseconds minRefreshInterval = 33ms;
|
static constexpr milliseconds minRefreshInterval = 33ms;
|
||||||
|
|
||||||
class TerminalViewPrivate
|
class TerminalViewPrivate
|
||||||
{
|
{
|
||||||
@@ -77,8 +78,8 @@ public:
|
|||||||
|
|
||||||
std::array<QColor, 20> m_currentColors;
|
std::array<QColor, 20> m_currentColors;
|
||||||
|
|
||||||
std::chrono::system_clock::time_point m_lastFlush{std::chrono::system_clock::now()};
|
system_clock::time_point m_lastFlush{system_clock::now()};
|
||||||
std::chrono::system_clock::time_point m_lastDoubleClick{std::chrono::system_clock::now()};
|
system_clock::time_point m_lastDoubleClick{system_clock::now()};
|
||||||
bool m_selectLineMode{false};
|
bool m_selectLineMode{false};
|
||||||
Cursor m_cursor;
|
Cursor m_cursor;
|
||||||
QTimer m_cursorBlinkTimer;
|
QTimer m_cursorBlinkTimer;
|
||||||
@@ -366,9 +367,8 @@ void TerminalView::writeToTerminal(const QByteArray &data, bool forceFlush)
|
|||||||
|
|
||||||
void TerminalView::flushVTerm(bool force)
|
void TerminalView::flushVTerm(bool force)
|
||||||
{
|
{
|
||||||
const std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
|
const system_clock::time_point now = system_clock::now();
|
||||||
const std::chrono::milliseconds timeSinceLastFlush
|
const milliseconds timeSinceLastFlush = duration_cast<milliseconds>(now - d->m_lastFlush);
|
||||||
= std::chrono::duration_cast<std::chrono::milliseconds>(now - d->m_lastFlush);
|
|
||||||
|
|
||||||
const bool shouldFlushImmediately = timeSinceLastFlush > minRefreshInterval;
|
const bool shouldFlushImmediately = timeSinceLastFlush > minRefreshInterval;
|
||||||
if (force || shouldFlushImmediately) {
|
if (force || shouldFlushImmediately) {
|
||||||
@@ -381,7 +381,7 @@ void TerminalView::flushVTerm(bool force)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!d->m_flushDelayTimer.isActive()) {
|
if (!d->m_flushDelayTimer.isActive()) {
|
||||||
const std::chrono::milliseconds timeToNextFlush = (minRefreshInterval - timeSinceLastFlush);
|
const milliseconds timeToNextFlush = (minRefreshInterval - timeSinceLastFlush);
|
||||||
d->m_flushDelayTimer.start(timeToNextFlush.count());
|
d->m_flushDelayTimer.start(timeToNextFlush.count());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1078,7 +1078,7 @@ void TerminalView::mousePressEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event->button() == Qt::LeftButton) {
|
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;
|
d->m_selectLineMode = true;
|
||||||
const Selection newSelection{d->m_surface->gridToPos(
|
const Selection newSelection{d->m_surface->gridToPos(
|
||||||
{0,
|
{0,
|
||||||
@@ -1139,7 +1139,7 @@ void TerminalView::mouseMoveEvent(QMouseEvent *event)
|
|||||||
d->m_scrollDirection = scrollVelocity;
|
d->m_scrollDirection = scrollVelocity;
|
||||||
|
|
||||||
if (d->m_scrollTimer.isActive() && scrollVelocity != 0) {
|
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)
|
if (d->m_scrollTimer.intervalAsDuration() != scrollInterval)
|
||||||
d->m_scrollTimer.setInterval(scrollInterval);
|
d->m_scrollTimer.setInterval(scrollInterval);
|
||||||
}
|
}
|
||||||
@@ -1209,7 +1209,7 @@ void TerminalView::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
setSelection(Selection{hit.start, hit.end, true});
|
setSelection(Selection{hit.start, hit.end, true});
|
||||||
|
|
||||||
d->m_lastDoubleClick = std::chrono::system_clock::now();
|
d->m_lastDoubleClick = system_clock::now();
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
@@ -134,7 +134,8 @@ QString BinaryVersionToolTipEventFilter::toolVersion(const CommandLine &cmd)
|
|||||||
return QString();
|
return QString();
|
||||||
Process proc;
|
Process proc;
|
||||||
proc.setCommand(cmd);
|
proc.setCommand(cmd);
|
||||||
proc.runBlocking(std::chrono::seconds(1));
|
using namespace std::chrono_literals;
|
||||||
|
proc.runBlocking(1s);
|
||||||
if (proc.result() != ProcessResult::FinishedWithSuccess)
|
if (proc.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return QString();
|
return QString();
|
||||||
return proc.allOutput();
|
return proc.allOutput();
|
||||||
|
@@ -222,7 +222,7 @@ static bool is32BitUserSpace()
|
|||||||
if (QSysInfo::WordSize == 32) {
|
if (QSysInfo::WordSize == 32) {
|
||||||
Process proc;
|
Process proc;
|
||||||
proc.setCommand({"getconf", {"LONG_BIT"}});
|
proc.setCommand({"getconf", {"LONG_BIT"}});
|
||||||
proc.runBlocking(std::chrono::seconds(3));
|
proc.runBlocking(3s);
|
||||||
if (proc.result() != ProcessResult::FinishedWithSuccess)
|
if (proc.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return true;
|
return true;
|
||||||
return proc.allOutput().trimmed() == "32";
|
return proc.allOutput().trimmed() == "32";
|
||||||
|
@@ -1000,7 +1000,8 @@ QAbstractItemModel *AndroidBuildApkStep::keystoreCertificates()
|
|||||||
|
|
||||||
Process keytoolProc;
|
Process keytoolProc;
|
||||||
keytoolProc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), params});
|
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)
|
if (keytoolProc.result() > ProcessResult::FinishedWithError)
|
||||||
QMessageBox::critical(nullptr, Tr::tr("Error"), Tr::tr("Failed to run keytool."));
|
QMessageBox::critical(nullptr, Tr::tr("Error"), Tr::tr("Failed to run keytool."));
|
||||||
else
|
else
|
||||||
|
@@ -599,7 +599,8 @@ QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(QString *error) const
|
|||||||
Process adbProc;
|
Process adbProc;
|
||||||
CommandLine cmd{adbToolPath(), {"devices"}};
|
CommandLine cmd{adbToolPath(), {"devices"}};
|
||||||
adbProc.setCommand(cmd);
|
adbProc.setCommand(cmd);
|
||||||
adbProc.runBlocking(std::chrono::seconds(30));
|
using namespace std::chrono_literals;
|
||||||
|
adbProc.runBlocking(30s);
|
||||||
if (adbProc.result() != ProcessResult::FinishedWithSuccess) {
|
if (adbProc.result() != ProcessResult::FinishedWithSuccess) {
|
||||||
if (error)
|
if (error)
|
||||||
*error = Tr::tr("Could not run: %1").arg(cmd.toUserOutput());
|
*error = Tr::tr("Could not run: %1").arg(cmd.toUserOutput());
|
||||||
|
@@ -274,7 +274,8 @@ void AndroidCreateKeystoreCertificate::buttonBoxAccepted()
|
|||||||
|
|
||||||
Process genKeyCertProc;
|
Process genKeyCertProc;
|
||||||
genKeyCertProc.setCommand(command);
|
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) {
|
if (genKeyCertProc.result() != ProcessResult::FinishedWithSuccess) {
|
||||||
QMessageBox::critical(this, Tr::tr("Error"),
|
QMessageBox::critical(this, Tr::tr("Error"),
|
||||||
|
@@ -97,7 +97,8 @@ public:
|
|||||||
{
|
{
|
||||||
Process process;
|
Process process;
|
||||||
process.setCommand({command(), {"-h"}});
|
process.setCommand({command(), {"-h"}});
|
||||||
process.runBlocking(std::chrono::seconds(2));
|
using namespace std::chrono_literals;
|
||||||
|
process.runBlocking(2s);
|
||||||
if (process.result() != ProcessResult::FinishedWithSuccess)
|
if (process.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -101,7 +101,8 @@ public:
|
|||||||
{
|
{
|
||||||
Process process;
|
Process process;
|
||||||
process.setCommand({command(), {"--show-config"}});
|
process.setCommand({command(), {"--show-config"}});
|
||||||
process.runBlocking(std::chrono::seconds(2));
|
using namespace std::chrono_literals;
|
||||||
|
process.runBlocking(2s);
|
||||||
if (process.result() != ProcessResult::FinishedWithSuccess)
|
if (process.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -29,6 +29,9 @@
|
|||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
namespace ClangFormat {
|
namespace ClangFormat {
|
||||||
|
|
||||||
enum class ReplacementsToKeep { OnlyIndent, IndentAndBefore, All };
|
enum class ReplacementsToKeep { OnlyIndent, IndentAndBefore, All };
|
||||||
@@ -525,7 +528,7 @@ public:
|
|||||||
struct CachedStyle {
|
struct CachedStyle {
|
||||||
clang::format::FormatStyle style = clang::format::getNoStyle();
|
clang::format::FormatStyle style = clang::format::getNoStyle();
|
||||||
QDateTime expirationTime;
|
QDateTime expirationTime;
|
||||||
void setCache(clang::format::FormatStyle newStyle, std::chrono::milliseconds timeout)
|
void setCache(clang::format::FormatStyle newStyle, milliseconds timeout)
|
||||||
{
|
{
|
||||||
style = newStyle;
|
style = newStyle;
|
||||||
expirationTime = QDateTime::currentDateTime().addMSecs(timeout.count());
|
expirationTime = QDateTime::currentDateTime().addMSecs(timeout.count());
|
||||||
@@ -851,12 +854,11 @@ clang::format::FormatStyle ClangFormatBaseIndenterPrivate::customSettingsStyle(
|
|||||||
return currentSettingsStyle;
|
return currentSettingsStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::chrono::milliseconds getCacheTimeout()
|
static milliseconds getCacheTimeout()
|
||||||
{
|
{
|
||||||
using namespace std::chrono_literals;
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
const int envCacheTimeout = qEnvironmentVariableIntValue("CLANG_FORMAT_CACHE_TIMEOUT", &ok);
|
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
|
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
|
const clang::format::FormatStyle &ClangFormatBaseIndenterPrivate::styleForFile() const
|
||||||
{
|
{
|
||||||
using namespace std::chrono_literals;
|
static const milliseconds cacheTimeout = getCacheTimeout();
|
||||||
static const std::chrono::milliseconds cacheTimeout = getCacheTimeout();
|
|
||||||
|
|
||||||
QDateTime time = QDateTime::currentDateTime();
|
QDateTime time = QDateTime::currentDateTime();
|
||||||
if (m_cachedStyle.expirationTime > time && !(m_cachedStyle.style == clang::format::getNoStyle()))
|
if (m_cachedStyle.expirationTime > time && !(m_cachedStyle.style == clang::format::getNoStyle()))
|
||||||
|
@@ -79,6 +79,8 @@ using namespace Core;
|
|||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace VcsBase;
|
using namespace VcsBase;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
|
||||||
namespace ClearCase::Internal {
|
namespace ClearCase::Internal {
|
||||||
@@ -1621,7 +1623,7 @@ CommandResult ClearCasePluginPrivate::runCleartoolProc(const FilePath &workingDi
|
|||||||
process.setEnvironment(env);
|
process.setEnvironment(env);
|
||||||
process.setCommand({m_settings.ccBinaryPath, arguments});
|
process.setCommand({m_settings.ccBinaryPath, arguments});
|
||||||
process.setWorkingDirectory(workingDir);
|
process.setWorkingDirectory(workingDir);
|
||||||
process.runBlocking(std::chrono::seconds(m_settings.timeOutS));
|
process.runBlocking(seconds(m_settings.timeOutS));
|
||||||
return CommandResult(process);
|
return CommandResult(process);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2286,7 +2288,7 @@ QString ClearCasePluginPrivate::runExtDiff(const FilePath &workingDir, const QSt
|
|||||||
process.setWorkingDirectory(workingDir);
|
process.setWorkingDirectory(workingDir);
|
||||||
process.setCodec(outputCodec ? outputCodec : QTextCodec::codecForName("UTF-8"));
|
process.setCodec(outputCodec ? outputCodec : QTextCodec::codecForName("UTF-8"));
|
||||||
process.setCommand(diff);
|
process.setCommand(diff);
|
||||||
process.runBlocking(std::chrono::seconds(timeOutS), EventLoopMode::On);
|
process.runBlocking(seconds(timeOutS), EventLoopMode::On);
|
||||||
if (process.result() != ProcessResult::FinishedWithSuccess)
|
if (process.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return {};
|
return {};
|
||||||
return process.allOutput();
|
return process.allOutput();
|
||||||
|
@@ -23,6 +23,7 @@ using namespace Core::Internal;
|
|||||||
using namespace Tasking;
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
static const char s_initData[] = R"(
|
static const char s_initData[] = R"(
|
||||||
@@ -291,7 +292,7 @@ public:
|
|||||||
QTC_ASSERT(!isRunning(), return);
|
QTC_ASSERT(!isRunning(), return);
|
||||||
m_input.m_input = input;
|
m_input.m_input = input;
|
||||||
}
|
}
|
||||||
void setTimeout(std::chrono::milliseconds timeout) {
|
void setTimeout(milliseconds timeout) {
|
||||||
QTC_ASSERT(!isRunning(), return);
|
QTC_ASSERT(!isRunning(), return);
|
||||||
m_timeout = timeout;
|
m_timeout = timeout;
|
||||||
}
|
}
|
||||||
@@ -333,7 +334,7 @@ signals:
|
|||||||
private:
|
private:
|
||||||
QPointer<JavaScriptEngine> m_engine;
|
QPointer<JavaScriptEngine> m_engine;
|
||||||
JavaScriptInput m_input;
|
JavaScriptInput m_input;
|
||||||
std::chrono::milliseconds m_timeout = 1000ms;
|
milliseconds m_timeout = 1000ms;
|
||||||
|
|
||||||
std::unique_ptr<QTimer> m_timer;
|
std::unique_ptr<QTimer> m_timer;
|
||||||
|
|
||||||
|
@@ -38,6 +38,8 @@
|
|||||||
using namespace Tasking;
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -163,7 +165,7 @@ void Locator::loadSettings()
|
|||||||
: QString("QuickOpen");
|
: QString("QuickOpen");
|
||||||
const Settings def;
|
const Settings def;
|
||||||
DB::beginGroup(settingsGroup);
|
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();
|
m_settings.useCenteredPopup = DB::value(kUseCenteredPopup, def.useCenteredPopup).toBool();
|
||||||
|
|
||||||
for (ILocatorFilter *filter : std::as_const(m_filters)) {
|
for (ILocatorFilter *filter : std::as_const(m_filters)) {
|
||||||
@@ -359,7 +361,7 @@ void Locator::setRefreshInterval(int interval)
|
|||||||
m_refreshTimer.setInterval(0);
|
m_refreshTimer.setInterval(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_refreshTimer.setInterval(std::chrono::minutes(interval));
|
m_refreshTimer.setInterval(minutes(interval));
|
||||||
m_refreshTimer.start();
|
m_refreshTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -366,7 +366,8 @@ static std::function<void(FilePath)> postCopyOperation()
|
|||||||
// to get it loaded as a plugin in Qt Creator.
|
// to get it loaded as a plugin in Qt Creator.
|
||||||
Process xattr;
|
Process xattr;
|
||||||
xattr.setCommand({"/usr/bin/xattr", {"-d", "com.apple.quarantine", filePath.absoluteFilePath().toString()}});
|
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);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
@@ -34,7 +35,7 @@ public:
|
|||||||
QPointer<FutureProgress> m_futureProgress;
|
QPointer<FutureProgress> m_futureProgress;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
FutureProgress::KeepOnFinishType m_keep = FutureProgress::HideOnFinish;
|
FutureProgress::KeepOnFinishType m_keep = FutureProgress::HideOnFinish;
|
||||||
std::chrono::seconds m_expectedDuration = 2s;
|
seconds m_expectedDuration = 2s;
|
||||||
};
|
};
|
||||||
|
|
||||||
ProcessProgressPrivate::ProcessProgressPrivate(ProcessProgress *progress, Process *process)
|
ProcessProgressPrivate::ProcessProgressPrivate(ProcessProgress *progress, Process *process)
|
||||||
@@ -150,7 +151,7 @@ void ProcessProgress::setProgressParser(const ProgressParser &parser)
|
|||||||
d.get(), &ProcessProgressPrivate::parseProgress);
|
d.get(), &ProcessProgressPrivate::parseProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessProgress::setExpectedDuration(std::chrono::seconds duration)
|
void ProcessProgress::setExpectedDuration(seconds duration)
|
||||||
{
|
{
|
||||||
d->m_expectedDuration = qMin(1s, duration);
|
d->m_expectedDuration = qMin(1s, duration);
|
||||||
}
|
}
|
||||||
|
@@ -34,13 +34,15 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
|
using namespace Core::Internal;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
|
|
||||||
static const char kSettingsGroup[] = "Progress";
|
static const char kSettingsGroup[] = "Progress";
|
||||||
static const char kDetailsPinned[] = "DetailsPinned";
|
static const char kDetailsPinned[] = "DetailsPinned";
|
||||||
static const bool kDetailsPinnedDefault = true;
|
static const bool kDetailsPinnedDefault = true;
|
||||||
static const std::chrono::milliseconds TimerInterval{100};
|
static const milliseconds TimerInterval{100};
|
||||||
|
|
||||||
using namespace Core::Internal;
|
|
||||||
using namespace Utils;
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
@@ -48,7 +50,7 @@ class ProgressTimer : public QObject
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProgressTimer(const QFutureInterfaceBase &futureInterface,
|
ProgressTimer(const QFutureInterfaceBase &futureInterface,
|
||||||
std::chrono::seconds expectedDuration,
|
seconds expectedDuration,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_futureInterface(futureInterface)
|
, m_futureInterface(futureInterface)
|
||||||
@@ -72,7 +74,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
QFutureInterfaceBase m_futureInterface;
|
QFutureInterfaceBase m_futureInterface;
|
||||||
std::chrono::seconds m_expectedDuration;
|
seconds m_expectedDuration;
|
||||||
int m_currentTime = 0;
|
int m_currentTime = 0;
|
||||||
QTimer m_timer;
|
QTimer m_timer;
|
||||||
};
|
};
|
||||||
@@ -779,7 +781,7 @@ FutureProgress *ProgressManager::addTask(const QFuture<void> &future, const QStr
|
|||||||
FutureProgress *ProgressManager::addTimedTask(const QFutureInterface<void> &futureInterface,
|
FutureProgress *ProgressManager::addTimedTask(const QFutureInterface<void> &futureInterface,
|
||||||
const QString &title,
|
const QString &title,
|
||||||
Id type,
|
Id type,
|
||||||
std::chrono::seconds expectedDuration,
|
seconds expectedDuration,
|
||||||
ProgressFlags flags)
|
ProgressFlags flags)
|
||||||
{
|
{
|
||||||
QFutureInterface<void> dummy(futureInterface); // Need mutable to access .future()
|
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,
|
FutureProgress *ProgressManager::addTimedTask(const QFuture<void> &future,
|
||||||
const QString &title,
|
const QString &title,
|
||||||
Id type,
|
Id type,
|
||||||
std::chrono::seconds expectedDuration,
|
seconds expectedDuration,
|
||||||
ProgressFlags flags)
|
ProgressFlags flags)
|
||||||
{
|
{
|
||||||
QFutureInterface<void> dummyFutureInterface;
|
QFutureInterface<void> dummyFutureInterface;
|
||||||
|
@@ -18,10 +18,12 @@
|
|||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
using namespace Tasking;
|
using namespace Tasking;
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
static const int ProgressResolution = 100; // 100 discrete values
|
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
|
class TaskProgressPrivate : public QObject
|
||||||
{
|
{
|
||||||
@@ -44,7 +46,7 @@ public:
|
|||||||
QPointer<FutureProgress> m_futureProgress;
|
QPointer<FutureProgress> m_futureProgress;
|
||||||
Id m_id;
|
Id m_id;
|
||||||
bool m_isAutoStopOnCancel = true;
|
bool m_isAutoStopOnCancel = true;
|
||||||
std::chrono::milliseconds m_halfLifeTimePerTask{1000};
|
milliseconds m_halfLifeTimePerTask{1000};
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
FutureProgress::KeepOnFinishType m_keep = FutureProgress::HideOnFinish;
|
FutureProgress::KeepOnFinishType m_keep = FutureProgress::HideOnFinish;
|
||||||
bool m_isSubtitleVisibleInStatusBar = false;
|
bool m_isSubtitleVisibleInStatusBar = false;
|
||||||
@@ -83,7 +85,7 @@ void TaskProgressPrivate::advanceProgress(int newValue)
|
|||||||
|
|
||||||
void TaskProgressPrivate::updateProgress()
|
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 halfLife = qRound(m_halfLifeTimePerTask / double_millis(TimerInterval));
|
||||||
const int pMin = ProgressResolution * m_currentProgress;
|
const int pMin = ProgressResolution * m_currentProgress;
|
||||||
const int pMax = ProgressResolution * (m_currentProgress + 1);
|
const int pMax = ProgressResolution * (m_currentProgress + 1);
|
||||||
@@ -149,7 +151,7 @@ void TaskProgress::setAutoStopOnCancel(bool enable)
|
|||||||
d->m_isAutoStopOnCancel = enable;
|
d->m_isAutoStopOnCancel = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskProgress::setHalfLifeTimePerTask(std::chrono::milliseconds duration)
|
void TaskProgress::setHalfLifeTimePerTask(milliseconds duration)
|
||||||
{
|
{
|
||||||
d->m_halfLifeTimePerTask = duration;
|
d->m_halfLifeTimePerTask = duration;
|
||||||
}
|
}
|
||||||
|
@@ -13,11 +13,12 @@ Q_LOGGING_CATEGORY(terminalSearchLog, "qtc.terminal.search", QtWarningMsg)
|
|||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
constexpr std::chrono::milliseconds debounceInterval = 100ms;
|
constexpr milliseconds debounceInterval = 100ms;
|
||||||
|
|
||||||
TerminalSearch::TerminalSearch(TerminalSolution::TerminalSurface *surface)
|
TerminalSearch::TerminalSearch(TerminalSolution::TerminalSurface *surface)
|
||||||
: m_surface(surface)
|
: m_surface(surface)
|
||||||
|
@@ -19,7 +19,8 @@ CppcheckRunner::CppcheckRunner(CppcheckTool &tool) : m_tool(tool)
|
|||||||
Process getConf;
|
Process getConf;
|
||||||
getConf.setCommand({"getconf", {"ARG_MAX"}});
|
getConf.setCommand({"getconf", {"ARG_MAX"}});
|
||||||
getConf.start();
|
getConf.start();
|
||||||
getConf.waitForFinished(std::chrono::seconds(2));
|
using namespace std::chrono_literals;
|
||||||
|
getConf.waitForFinished(2s);
|
||||||
const QByteArray argMax = getConf.rawStdOut().replace("\n", "");
|
const QByteArray argMax = getConf.rawStdOut().replace("\n", "");
|
||||||
m_maxArgumentsLength = std::max(argMax.toInt(), m_maxArgumentsLength);
|
m_maxArgumentsLength = std::max(argMax.toInt(), m_maxArgumentsLength);
|
||||||
}
|
}
|
||||||
|
@@ -621,7 +621,8 @@ void DebuggerItemModel::autoDetectGdbOrLldbDebuggers(const FilePaths &searchPath
|
|||||||
if (searchPaths.front().osType() == OsTypeMac) {
|
if (searchPaths.front().osType() == OsTypeMac) {
|
||||||
Process proc;
|
Process proc;
|
||||||
proc.setCommand({"xcrun", {"--find", "lldb"}});
|
proc.setCommand({"xcrun", {"--find", "lldb"}});
|
||||||
proc.runBlocking(std::chrono::seconds(2));
|
using namespace std::chrono_literals;
|
||||||
|
proc.runBlocking(2s);
|
||||||
// FIXME:
|
// FIXME:
|
||||||
if (proc.result() == ProcessResult::FinishedWithSuccess) {
|
if (proc.result() == ProcessResult::FinishedWithSuccess) {
|
||||||
QString lPath = proc.allOutput().trimmed();
|
QString lPath = proc.allOutput().trimmed();
|
||||||
|
@@ -213,7 +213,8 @@ void LldbEngine::setupEngine()
|
|||||||
|
|
||||||
void LldbEngine::handleLldbStarted()
|
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..."));
|
showStatusMessage(Tr::tr("Setting up inferior..."));
|
||||||
|
|
||||||
|
@@ -217,7 +217,8 @@ static QByteArray decodeProvisioningProfile(const QString &path)
|
|||||||
Process p;
|
Process p;
|
||||||
// path is assumed to be valid file path to .mobileprovision
|
// path is assumed to be valid file path to .mobileprovision
|
||||||
p.setCommand({"openssl", {"smime", "-inform", "der", "-verify", "-in", path}});
|
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)
|
if (p.result() != ProcessResult::FinishedWithSuccess)
|
||||||
qCDebug(iosCommonLog) << "Reading signed provisioning file failed" << path;
|
qCDebug(iosCommonLog) << "Reading signed provisioning file failed" << path;
|
||||||
return p.cleanedStdOut().toLatin1();
|
return p.cleanedStdOut().toLatin1();
|
||||||
|
@@ -42,7 +42,8 @@ void XcodeProbe::detectDeveloperPaths()
|
|||||||
{
|
{
|
||||||
Utils::Process selectedXcode;
|
Utils::Process selectedXcode;
|
||||||
selectedXcode.setCommand({"/usr/bin/xcode-select", {"--print-path"}});
|
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)
|
if (selectedXcode.result() != ProcessResult::FinishedWithSuccess)
|
||||||
qCWarning(probeLog)
|
qCWarning(probeLog)
|
||||||
<< QString::fromLatin1("Could not detect selected Xcode using xcode-select");
|
<< QString::fromLatin1("Could not detect selected Xcode using xcode-select");
|
||||||
|
@@ -596,7 +596,8 @@ IosDeviceToolHandlerPrivate::IosDeviceToolHandlerPrivate(const IosDeviceType &de
|
|||||||
qCDebug(toolHandlerLog) << "IosToolHandler runEnv:" << env.toStringList();
|
qCDebug(toolHandlerLog) << "IosToolHandler runEnv:" << env.toStringList();
|
||||||
process->setEnvironment(env);
|
process->setEnvironment(env);
|
||||||
process->setProcessMode(ProcessMode::Writer);
|
process->setProcessMode(ProcessMode::Writer);
|
||||||
process->setReaperTimeout(std::chrono::milliseconds(1500));
|
using namespace std::chrono_literals;
|
||||||
|
process->setReaperTimeout(1500ms);
|
||||||
|
|
||||||
QObject::connect(process.get(), &Process::readyReadStandardOutput,
|
QObject::connect(process.get(), &Process::readyReadStandardOutput,
|
||||||
q, [this] { subprocessHasData(); });
|
q, [this] { subprocessHasData(); });
|
||||||
|
@@ -52,7 +52,8 @@ QString McuPackageExecutableVersionDetector::parseVersion(const FilePath &packag
|
|||||||
Process process;
|
Process process;
|
||||||
process.setCommand({binaryPath, m_detectionArgs});
|
process.setCommand({binaryPath, m_detectionArgs});
|
||||||
process.start();
|
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 {};
|
||||||
|
|
||||||
return matchRegExp(process.allOutput(), m_detectionRegExp);
|
return matchRegExp(process.allOutput(), m_detectionRegExp);
|
||||||
|
@@ -93,7 +93,8 @@ static bool
|
|||||||
qDebug("In %s, running:\n%s\n", qPrintable(workingDirectory.toUserOutput()),
|
qDebug("In %s, running:\n%s\n", qPrintable(workingDirectory.toUserOutput()),
|
||||||
qPrintable(cmd.toUserOutput()));
|
qPrintable(cmd.toUserOutput()));
|
||||||
process.setCommand(cmd);
|
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) {
|
if (process.result() != Utils::ProcessResult::FinishedWithSuccess) {
|
||||||
*errorMessage = QString("Generator script failed: %1").arg(process.exitMessage());
|
*errorMessage = QString("Generator script failed: %1").arg(process.exitMessage());
|
||||||
const QString stdErr = process.cleanedStdErr();
|
const QString stdErr = process.cleanedStdErr();
|
||||||
|
@@ -390,7 +390,8 @@ void ProcessExtraCompiler::runInThread(QPromise<FileNameToContentsHash> &promise
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
while (!promise.isCanceled()) {
|
while (!promise.isCanceled()) {
|
||||||
if (process.waitForFinished(std::chrono::milliseconds(200)))
|
using namespace std::chrono_literals;
|
||||||
|
if (process.waitForFinished(200ms))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1325,7 +1325,8 @@ void SimpleTargetRunnerPrivate::stop()
|
|||||||
switch (m_state) {
|
switch (m_state) {
|
||||||
case Run:
|
case Run:
|
||||||
m_process.stop();
|
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. "
|
q->appendMessage(Tr::tr("Remote process did not finish in time. "
|
||||||
"Connectivity lost?"), ErrorMessageFormat);
|
"Connectivity lost?"), ErrorMessageFormat);
|
||||||
m_process.close();
|
m_process.close();
|
||||||
|
@@ -86,7 +86,8 @@ static PythonLanguageServerState checkPythonLanguageServer(const FilePath &pytho
|
|||||||
|
|
||||||
Process pythonProcess;
|
Process pythonProcess;
|
||||||
pythonProcess.setCommand({python, {"-m", "pip", "-V"}});
|
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 "))
|
if (pythonProcess.allOutput().startsWith("pip "))
|
||||||
return {PythonLanguageServerState::CanBeInstalled, lspPath};
|
return {PythonLanguageServerState::CanBeInstalled, lspPath};
|
||||||
return {PythonLanguageServerState::CanNotBeInstalled, FilePath()};
|
return {PythonLanguageServerState::CanNotBeInstalled, FilePath()};
|
||||||
|
@@ -71,7 +71,8 @@ static Interpreter createInterpreter(const FilePath &python,
|
|||||||
Process pythonProcess;
|
Process pythonProcess;
|
||||||
pythonProcess.setProcessChannelMode(QProcess::MergedChannels);
|
pythonProcess.setProcessChannelMode(QProcess::MergedChannels);
|
||||||
pythonProcess.setCommand({python, {"--version"}});
|
pythonProcess.setCommand({python, {"--version"}});
|
||||||
pythonProcess.runBlocking(std::chrono::seconds(1));
|
using namespace std::chrono_literals;
|
||||||
|
pythonProcess.runBlocking(1s);
|
||||||
if (pythonProcess.result() == ProcessResult::FinishedWithSuccess)
|
if (pythonProcess.result() == ProcessResult::FinishedWithSuccess)
|
||||||
result.name = pythonProcess.cleanedStdOut().trimmed();
|
result.name = pythonProcess.cleanedStdOut().trimmed();
|
||||||
if (result.name.isEmpty())
|
if (result.name.isEmpty())
|
||||||
|
@@ -149,7 +149,8 @@ QString pythonName(const FilePath &pythonPath)
|
|||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
Process pythonProcess;
|
Process pythonProcess;
|
||||||
pythonProcess.setCommand({pythonPath, {"--version"}});
|
pythonProcess.setCommand({pythonPath, {"--version"}});
|
||||||
pythonProcess.runBlocking(std::chrono::seconds(2));
|
using namespace std::chrono_literals;
|
||||||
|
pythonProcess.runBlocking(2s);
|
||||||
if (pythonProcess.result() != ProcessResult::FinishedWithSuccess)
|
if (pythonProcess.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return {};
|
return {};
|
||||||
name = pythonProcess.allOutput().trimmed();
|
name = pythonProcess.allOutput().trimmed();
|
||||||
|
@@ -229,7 +229,8 @@ QString QbsProfileManager::runQbsConfig(QbsConfigOp op, const QString &key, cons
|
|||||||
Utils::Process qbsConfig;
|
Utils::Process qbsConfig;
|
||||||
qbsConfig.setCommand({qbsConfigExe, args});
|
qbsConfig.setCommand({qbsConfigExe, args});
|
||||||
qbsConfig.start();
|
qbsConfig.start();
|
||||||
if (!qbsConfig.waitForFinished(std::chrono::seconds(5))) {
|
using namespace std::chrono_literals;
|
||||||
|
if (!qbsConfig.waitForFinished(5s)) {
|
||||||
Core::MessageManager::writeFlashing(
|
Core::MessageManager::writeFlashing(
|
||||||
Tr::tr("Failed to run qbs config: %1").arg(qbsConfig.errorString()));
|
Tr::tr("Failed to run qbs config: %1").arg(qbsConfig.errorString()));
|
||||||
} else if (qbsConfig.exitCode() != 0) {
|
} else if (qbsConfig.exitCode() != 0) {
|
||||||
|
@@ -215,7 +215,8 @@ QbsSession::~QbsSession()
|
|||||||
d->qbsProcess->disconnect(this);
|
d->qbsProcess->disconnect(this);
|
||||||
if (d->qbsProcess->state() == QProcess::Running) {
|
if (d->qbsProcess->state() == QProcess::Running) {
|
||||||
sendQuitPacket();
|
sendQuitPacket();
|
||||||
d->qbsProcess->waitForFinished(std::chrono::seconds(10));
|
using namespace std::chrono_literals;
|
||||||
|
d->qbsProcess->waitForFinished(10s);
|
||||||
}
|
}
|
||||||
delete d->qbsProcess;
|
delete d->qbsProcess;
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,8 @@ static QString getQbsVersion(const FilePath &qbsExe)
|
|||||||
Process qbsProc;
|
Process qbsProc;
|
||||||
qbsProc.setCommand({qbsExe, {"--version"}});
|
qbsProc.setCommand({qbsExe, {"--version"}});
|
||||||
qbsProc.start();
|
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 {};
|
||||||
return QString::fromLocal8Bit(qbsProc.rawStdOut()).trimmed();
|
return QString::fromLocal8Bit(qbsProc.rawStdOut()).trimmed();
|
||||||
}
|
}
|
||||||
|
@@ -43,6 +43,9 @@
|
|||||||
#include <QFileSystemWatcher>
|
#include <QFileSystemWatcher>
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -75,15 +78,12 @@ class PreviewTimeStampProvider : public TimeStampProviderInterface
|
|||||||
public:
|
public:
|
||||||
Sqlite::TimeStamp timeStamp(Utils::SmallStringView) const override
|
Sqlite::TimeStamp timeStamp(Utils::SmallStringView) const override
|
||||||
{
|
{
|
||||||
auto now = std::chrono::steady_clock::now();
|
return duration_cast<seconds>(steady_clock::now().time_since_epoch()).count();
|
||||||
|
|
||||||
return std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Sqlite::TimeStamp pause() const override
|
Sqlite::TimeStamp pause() const override
|
||||||
{
|
{
|
||||||
using namespace std::chrono_literals;
|
return duration_cast<seconds>(1h).count();
|
||||||
return std::chrono::duration_cast<std::chrono::seconds>(1h).count();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -307,7 +307,6 @@ void QmlDesignerProjectManager::editorOpened(::Core::IEditor *) {}
|
|||||||
|
|
||||||
void QmlDesignerProjectManager::currentEditorChanged(::Core::IEditor *)
|
void QmlDesignerProjectManager::currentEditorChanged(::Core::IEditor *)
|
||||||
{
|
{
|
||||||
using namespace std::chrono_literals;
|
|
||||||
m_previewImageCacheData->timer.start(10s);
|
m_previewImageCacheData->timer.start(10s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -107,7 +107,8 @@ EnvironmentItems QnxUtils::qnxEnvironmentFromEnvFile(const FilePath &filePath)
|
|||||||
|
|
||||||
// waiting for finish
|
// waiting for finish
|
||||||
QApplication::setOverrideCursor(Qt::BusyCursor);
|
QApplication::setOverrideCursor(Qt::BusyCursor);
|
||||||
bool waitResult = process.waitForFinished(std::chrono::seconds(10));
|
using namespace std::chrono_literals;
|
||||||
|
bool waitResult = process.waitForFinished(10s);
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
if (!waitResult)
|
if (!waitResult)
|
||||||
return items;
|
return items;
|
||||||
|
@@ -450,7 +450,8 @@ bool SshProcessInterface::runInShell(const CommandLine &command, const QByteArra
|
|||||||
process.setCommand(cmd);
|
process.setCommand(cmd);
|
||||||
process.setWriteData(data);
|
process.setWriteData(data);
|
||||||
process.start();
|
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) {
|
if (!isFinished) {
|
||||||
Core::MessageManager::writeFlashing(tr("Can't send control signal to the %1 device. "
|
Core::MessageManager::writeFlashing(tr("Can't send control signal to the %1 device. "
|
||||||
"The device might have been disconnected.")
|
"The device might have been disconnected.")
|
||||||
|
@@ -51,7 +51,8 @@ static bool isSilverSearcherAvailable()
|
|||||||
Process silverSearcherProcess;
|
Process silverSearcherProcess;
|
||||||
silverSearcherProcess.setCommand({"ag", {"--version"}});
|
silverSearcherProcess.setCommand({"ag", {"--version"}});
|
||||||
silverSearcherProcess.start();
|
silverSearcherProcess.start();
|
||||||
return silverSearcherProcess.waitForFinished(std::chrono::seconds(1))
|
using namespace std::chrono_literals;
|
||||||
|
return silverSearcherProcess.waitForFinished(1s)
|
||||||
&& silverSearcherProcess.cleanedStdOut().contains("ag version");
|
&& silverSearcherProcess.cleanedStdOut().contains("ag version");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -192,7 +192,8 @@ void ValgrindMemcheckParserTest::initTest(const QString &testfile, const QString
|
|||||||
m_process->setCommand({FilePath::fromString(fakeValgrind), args + otherArgs});
|
m_process->setCommand({FilePath::fromString(fakeValgrind), args + otherArgs});
|
||||||
m_process->start();
|
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);
|
QCOMPARE(m_process->state(), QProcess::Running);
|
||||||
QVERIFY2(m_process->error() == QProcess::UnknownError, qPrintable(m_process->errorString()));
|
QVERIFY2(m_process->error() == QProcess::UnknownError, qPrintable(m_process->errorString()));
|
||||||
QVERIFY(m_server->waitForNewConnection(5000));
|
QVERIFY(m_server->waitForNewConnection(5000));
|
||||||
|
@@ -19,6 +19,8 @@
|
|||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
|
|
||||||
namespace VcsBase {
|
namespace VcsBase {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -115,7 +117,7 @@ void VcsCommandPrivate::setupProcess(Process *process, const Job &job)
|
|||||||
|
|
||||||
ProcessProgress *progress = new ProcessProgress(process);
|
ProcessProgress *progress = new ProcessProgress(process);
|
||||||
progress->setDisplayName(m_displayName);
|
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)
|
if (m_progressParser)
|
||||||
progress->setProgressParser(m_progressParser);
|
progress->setProgressParser(m_progressParser);
|
||||||
}
|
}
|
||||||
@@ -307,7 +309,7 @@ CommandResult VcsCommand::runBlockingHelper(const CommandLine &command, int time
|
|||||||
|
|
||||||
const EventLoopMode eventLoopMode = d->eventLoopMode();
|
const EventLoopMode eventLoopMode = d->eventLoopMode();
|
||||||
process.setTimeOutMessageBoxEnabled(eventLoopMode == EventLoopMode::On);
|
process.setTimeOutMessageBoxEnabled(eventLoopMode == EventLoopMode::On);
|
||||||
process.runBlocking(std::chrono::seconds(timeoutS), eventLoopMode);
|
process.runBlocking(seconds(timeoutS), eventLoopMode);
|
||||||
d->handleDone(&process, job);
|
d->handleDone(&process, job);
|
||||||
|
|
||||||
return CommandResult(process);
|
return CommandResult(process);
|
||||||
|
@@ -11,6 +11,8 @@
|
|||||||
#include <QSharedMemory>
|
#include <QSharedMemory>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
|
|
||||||
namespace SharedTools {
|
namespace SharedTools {
|
||||||
|
|
||||||
static const int instancesSize = 1024;
|
static const int instancesSize = 1024;
|
||||||
@@ -179,12 +181,11 @@ public:
|
|||||||
: QtSingleApplication(id, argc, argv)
|
: QtSingleApplication(id, argc, argv)
|
||||||
, m_align(21, QChar::Space)
|
, 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 {
|
bool notify(QObject *receiver, QEvent *event) override {
|
||||||
if (m_inNotify)
|
if (m_inNotify)
|
||||||
return QtSingleApplication::notify(receiver, event);
|
return QtSingleApplication::notify(receiver, event);
|
||||||
using namespace std::chrono;
|
|
||||||
const auto start = system_clock::now();
|
const auto start = system_clock::now();
|
||||||
const QPointer<QObject> p(receiver);
|
const QPointer<QObject> p(receiver);
|
||||||
const QString className = QLatin1String(receiver->metaObject()->className());
|
const QString className = QLatin1String(receiver->metaObject()->className());
|
||||||
@@ -213,7 +214,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool m_inNotify = false;
|
bool m_inNotify = false;
|
||||||
const QString m_align;
|
const QString m_align;
|
||||||
std::chrono::milliseconds m_threshold{100};
|
milliseconds m_threshold{100};
|
||||||
};
|
};
|
||||||
|
|
||||||
QtSingleApplication *createApplication(const QString &id, int &argc, char **argv)
|
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
|
qDebug() << "Change the freeze detection threshold by setting the" << s_freezeDetector
|
||||||
<< "env var to a different numeric value (in ms).";
|
<< "env var to a different numeric value (in ms).";
|
||||||
ApplicationWithFreezerDetector *app = new ApplicationWithFreezerDetector(id, argc, argv);
|
ApplicationWithFreezerDetector *app = new ApplicationWithFreezerDetector(id, argc, argv);
|
||||||
app->setFreezeTreshold(std::chrono::milliseconds(*freezeDetector));
|
app->setFreezeTreshold(milliseconds(*freezeDetector));
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,13 +6,12 @@
|
|||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
|
||||||
using namespace std::literals::chrono_literals;
|
using namespace std::chrono;
|
||||||
|
|
||||||
EventSpy::EventSpy(uint eventType)
|
EventSpy::EventSpy(uint eventType)
|
||||||
: startTime(std::chrono::steady_clock::now()),
|
: startTime(steady_clock::now())
|
||||||
eventType(eventType)
|
, eventType(eventType)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
bool EventSpy::waitForEvent()
|
bool EventSpy::waitForEvent()
|
||||||
{
|
{
|
||||||
@@ -26,15 +25,12 @@ bool EventSpy::event(QEvent *event)
|
|||||||
{
|
{
|
||||||
if (event->type() == eventType) {
|
if (event->type() == eventType) {
|
||||||
eventHappened = true;
|
eventHappened = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventSpy::shouldRun() const
|
bool EventSpy::shouldRun() const
|
||||||
{
|
{
|
||||||
return !eventHappened
|
return !eventHappened && (steady_clock::now() - startTime) < 1s;
|
||||||
&& (std::chrono::steady_clock::now() - startTime) < 1s;
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user