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> { fn song(&self) -> Option<Song> {
if self.obj().playlist_pos() < 0 { match self.obj().playlist_pos() {
None playlist_pos if playlist_pos < 0 => None,
} else { playlist_pos => Some(
let song: Song = self self.obj()
.obj()
.playlist_model() .playlist_model()
.item(self.obj().playlist_pos() as u32) .item(playlist_pos as u32)
.unwrap() .unwrap()
.dynamic_cast() .dynamic_cast()
.unwrap(); .unwrap(),
),
Some(song)
} }
} }