From 262ad31e124e08615ee8e31a8093d3fd80e08c56 Mon Sep 17 00:00:00 2001 From: Aleks Margarian Date: Tue, 14 Apr 2020 22:41:39 -0700 Subject: [PATCH] Time elapsed is no longer broken oopsie --- gui/cProgress.cpp | 8 +++++--- gui/cProgress.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gui/cProgress.cpp b/gui/cProgress.cpp index 3d6f1ec..1ff5edf 100644 --- a/gui/cProgress.cpp +++ b/gui/cProgress.cpp @@ -9,7 +9,8 @@ cProgress::cProgress(cMain* main, wxString taskName, cancel_flag& cancelFlag, fl value = 0; frequency = updateFreq; maxValue = maximum; - etaTimePoints.push(std::make_pair(0, Clock::now())); + startTime = Clock::now(); + etaTimePoints.push(std::make_pair(0, startTime)); this->SetIcon(wxICON(APP_ICON)); this->SetMinSize(wxSize(400, -1)); @@ -87,10 +88,11 @@ inline void cProgress::Update(bool force) { progressPercent->SetLabel(wxString::Format("%.2f%%", float(value) * 100 / maxValue)); progressTotal->SetLabel(wxString::Format("%u / %u", value.load(), maxValue)); - auto& timePoint = etaTimePoints.front(); - auto elapsed = ch::duration_cast(now - timePoint.second); + auto elapsed = ch::duration_cast(now - startTime); progressTimeElapsed->SetLabel("Elapsed: " + FormatTime(elapsed)); + auto& timePoint = etaTimePoints.front(); + auto etaElapsed = ch::duration_cast(now - timePoint.second); auto etaCount = value - timePoint.first; auto etaDivisor = float(maxValue - etaCount) / etaCount; auto eta = etaDivisor ? ch::duration_cast(elapsed * etaDivisor) : ch::seconds::zero(); diff --git a/gui/cProgress.h b/gui/cProgress.h index 463877b..6f4bdc9 100644 --- a/gui/cProgress.h +++ b/gui/cProgress.h @@ -42,6 +42,7 @@ class cProgress : public wxFrame bool finished = false; std::queue> etaTimePoints; + Clock::time_point startTime; Clock::time_point lastUpdate; float frequency; std::atomic_uint32_t value;