Fix #18
Vladimir Bauer
8 years ago
| 101 | 101 | |
| 102 | 102 | // RemoveBar removes the bar at next render cycle |
| 103 | 103 | func (p *Progress) RemoveBar(b *Bar) bool { |
| 104 | return b.askToComplete(true) | |
| 104 | result := b.askToComplete(true) | |
| 105 | <-b.done | |
| 106 | return result | |
| 105 | 107 | } |
| 106 | 108 | |
| 107 | 109 | // UpdateBarPriority provides a way to change bar's order position. |
| 185 | 187 | |
| 186 | 188 | for _, br := range s.renderByPriority(tw, pSyncer, aSyncer) { |
| 187 | 189 | r := <-br.ready |
| 188 | _, err = s.cw.ReadFrom(r) | |
| 190 | if !r.toRemove { | |
| 191 | _, err = s.cw.ReadFrom(r) | |
| 192 | } else { | |
| 193 | s.heapUpdated = heap.Remove(s.bHeap, br.bar.index) != nil | |
| 194 | } | |
| 189 | 195 | if !br.bar.completed && r.toComplete { |
| 190 | close(br.bar.shutdown) | |
| 191 | 196 | br.bar.completed = true |
| 192 | } | |
| 193 | if r.toRemove { | |
| 194 | s.heapUpdated = heap.Remove(s.bHeap, br.bar.index) != nil | |
| 197 | defer close(br.bar.shutdown) | |
| 195 | 198 | } |
| 196 | 199 | } |
| 197 | 200 | |