fix: Avoid deadlock in ProgressBar::redraw()
This commit is contained in:
@@ -75,11 +75,11 @@ private:
|
||||
bool active = true;
|
||||
bool paused = false;
|
||||
bool haveUpdate = true;
|
||||
|
||||
/** Helps avoid unnecessary redraws, see `draw()` */
|
||||
std::string lastOutput;
|
||||
};
|
||||
|
||||
/** Helps avoid unnecessary redraws, see `redraw()` */
|
||||
Sync<std::string> lastOutput_;
|
||||
|
||||
Sync<State> state_;
|
||||
|
||||
std::thread updateThread;
|
||||
@@ -371,10 +371,10 @@ public:
|
||||
*/
|
||||
void redraw(std::string newOutput)
|
||||
{
|
||||
auto state(state_.lock());
|
||||
if (newOutput != state->lastOutput) {
|
||||
auto lastOutput(lastOutput_.lock());
|
||||
if (newOutput != *lastOutput) {
|
||||
writeToStderr(newOutput);
|
||||
state->lastOutput = std::move(newOutput);
|
||||
*lastOutput = std::move(newOutput);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user