From 0fc5f6722fd215e7b49a47abb46e3329af677c08 Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Sat, 26 Mar 2022 23:41:44 +0100 Subject: [PATCH] update playlist and check for new one at the end, to prevent index out of bound --- src/input/playlist.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/input/playlist.rs b/src/input/playlist.rs index cf5ecd44..95aab88d 100644 --- a/src/input/playlist.rs +++ b/src/input/playlist.rs @@ -228,9 +228,8 @@ impl Iterator for CurrentProgram { return Some(self.current_node.clone()); } + if self.index < self.nodes.len() { - self.check_update(false); - self.check_for_next_playlist(); let mut is_last = false; if self.index == self.nodes.len() - 1 { @@ -242,6 +241,10 @@ impl Iterator for CurrentProgram { self.current_node.next_ad = self.is_ad(self.index, true); self.index += 1; + // update playlist should happen after current clip, + // to prevent unknown behaviors. + self.check_update(false); + self.check_for_next_playlist(); Some(self.current_node.clone()) } else { let last_playlist = self.json_path.clone();