fix: Do not crash due to unavailable tracks in queue
* fix: Do not crash due to unavailable tracks in queue Fixes #1616 * fix: Also use checked multiplication to prevent overflow
This commit is contained in:
committed by
GitHub
parent
46eb9dc1dd
commit
6ffaf3bd22
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Skip unplayable tracks
|
- Skip unplayable tracks
|
||||||
- Queue UI correctly plays a track when clicking on an already selected item
|
- Queue UI correctly plays a track when clicking on an already selected item
|
||||||
- Swap foreground and background colors for command line input
|
- Swap foreground and background colors for command line input
|
||||||
|
- Do not crash due to unavailable tracks in queue
|
||||||
|
|
||||||
## [1.2.2]
|
## [1.2.2]
|
||||||
|
|
||||||
|
|||||||
@@ -190,8 +190,10 @@ impl View for StatusBar {
|
|||||||
|
|
||||||
if let Some(t) = self.queue.get_current() {
|
if let Some(t) = self.queue.get_current() {
|
||||||
printer.with_color(style_bar, |printer| {
|
printer.with_color(style_bar, |printer| {
|
||||||
let duration_width =
|
let duration_width = elapsed_ms
|
||||||
(((printer.size.x as u32) * elapsed_ms) / t.duration()) as usize;
|
.checked_mul(printer.size.x as u32)
|
||||||
|
.and_then(|v| v.checked_div(t.duration()))
|
||||||
|
.unwrap_or(0) as usize;
|
||||||
printer.print((0, 0), &"━".repeat(duration_width + 1));
|
printer.print((0, 0), &"━".repeat(duration_width + 1));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user