From f0d33642134b8c388d174ad3ca7936a83db1f9a9 Mon Sep 17 00:00:00 2001 From: Daniel Wolf Date: Sat, 9 Sep 2017 21:41:50 +0200 Subject: [PATCH] Made ProgressBar destruction behavior configurable --- src/tools/ProgressBar.cpp | 4 +++- src/tools/ProgressBar.h | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/tools/ProgressBar.cpp b/src/tools/ProgressBar.cpp index 0626f6e..404a6b8 100644 --- a/src/tools/ProgressBar.cpp +++ b/src/tools/ProgressBar.cpp @@ -87,7 +87,9 @@ void ProgressBar::updateLoop() { std::this_thread::sleep_for(animationInterval); } - updateText(""); + if (clearOnDestruction) { + updateText(""); + } } void ProgressBar::updateText(const string& text) { diff --git a/src/tools/ProgressBar.h b/src/tools/ProgressBar.h index 8406493..0c005c7 100644 --- a/src/tools/ProgressBar.h +++ b/src/tools/ProgressBar.h @@ -48,6 +48,14 @@ public: ~ProgressBar(); void reportProgress(double value) override; + bool getClearOnDestruction() const { + return clearOnDestruction; + } + + void setClearOnDestruction(bool value) { + clearOnDestruction = value; + } + private: void updateLoop(); void updateText(const std::string& text); @@ -59,4 +67,5 @@ private: std::ostream& stream; std::string currentText; int animationIndex = 0; + bool clearOnDestruction = true; };