From e50a3470c1810d5c80ff8f96e03a50dbc9fba254 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 4 Apr 2016 13:37:56 -0700 Subject: QML UI: rate limit git progress output Signed-off-by: Dirk Hohndel --- qt-mobile/qmlmanager.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'qt-mobile') diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index 6a38078a8..048e787cf 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -36,14 +36,19 @@ extern "C" int gitProgressCB(int percent, const char *text) { static QElapsedTimer timer; static qint64 lastTime = 0; + static int lastPercent = -100; if (!timer.isValid() || percent == 0) { timer.restart(); lastTime = 0; + lastPercent = -100; } QMLManager *self = QMLManager::instance(); if (self) { qint64 elapsed = timer.elapsed(); + // don't show the same status twice in 200ms + if (percent == lastPercent && elapsed - lastTime < 200) + return 0; self->loadDiveProgress(percent); QString logText = QString::number(elapsed / 1000.0, 'f', 1) + " / " + QString::number((elapsed - lastTime) / 1000.0, 'f', 3) + QString(" : git progress %1 (%2)").arg(percent).arg(text); -- cgit v1.2.3-70-g09d2