fix crash on end of playlist

apparently playlist_pos() can and will change from >0 to -1 between
those two queries
This commit is contained in:
Erica Z 2024-11-06 12:11:14 +01:00
parent ab96330fbd
commit f8b47ca9b6

View file

@ -518,18 +518,16 @@ mod imp {
}
fn song(&self) -> Option<Song> {
if self.obj().playlist_pos() < 0 {
None
} else {
let song: Song = self
.obj()
.playlist_model()
.item(self.obj().playlist_pos() as u32)
.unwrap()
.dynamic_cast()
.unwrap();
Some(song)
match self.obj().playlist_pos() {
playlist_pos if playlist_pos < 0 => None,
playlist_pos => Some(
self.obj()
.playlist_model()
.item(playlist_pos as u32)
.unwrap()
.dynamic_cast()
.unwrap(),
),
}
}