mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-15 02:36:16 +02:00
fix: Avoid deadlock in ProgressBar::redraw()
This commit is contained in:
parent
e10ea78f93
commit
c955563b64
1 changed files with 6 additions and 6 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue