From 08e29070c2352b90260eb769ead5cf5673d50fb9 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 1 Oct 2016 02:04:04 +0300 Subject: [PATCH] Fix possible uninit m_pb, print \33[K (clreol) in the end for less glitches in xfce4-terminal and \r for better window resize --- libgrive/src/http/CurlAgent.cc | 2 +- libgrive/src/util/ProgressBar.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libgrive/src/http/CurlAgent.cc b/libgrive/src/http/CurlAgent.cc index 2e1f46d..eee9a8d 100644 --- a/libgrive/src/http/CurlAgent.cc +++ b/libgrive/src/http/CurlAgent.cc @@ -71,7 +71,7 @@ struct CurlAgent::Impl static struct curl_slist* SetHeader( CURL* handle, const Header& hdr ); CurlAgent::CurlAgent() : Agent(), - m_pimpl( new Impl ) + m_pimpl( new Impl ), m_pb( 0 ) { m_pimpl->curl = ::curl_easy_init(); } diff --git a/libgrive/src/util/ProgressBar.cc b/libgrive/src/util/ProgressBar.cc index b21aedd..efd71bc 100644 --- a/libgrive/src/util/ProgressBar.cc +++ b/libgrive/src/util/ProgressBar.cc @@ -66,7 +66,7 @@ void ProgressBar::reportProgress(u64_t total, u64_t processed) int dotz = round(fraction * totalDots); int count = 0; // delete previous output line - printf("\r\33[2K [%3.0f%%] [", fraction * 100); + printf("\r [%3.0f%%] [", fraction * 100); for (; count < dotz - 1; count++) putchar('='); putchar('>'); @@ -76,6 +76,7 @@ void ProgressBar::reportProgress(u64_t total, u64_t processed) printBytes(processed); putchar('/'); printBytes(total); + printf("\33[K\r"); if (point == 1000) putchar('\n'); fflush(stdout);