From f5d3358b5fed2e5cf0c141e380f64d377a3f3093 Mon Sep 17 00:00:00 2001 From: Stephan Sundermann Date: Wed, 25 Dec 2013 10:39:15 +0100 Subject: [PATCH] Bugfix: Fixed NullReferenceException when search returned 0 results --- .../Menu/SongMenu/CSongMenuTileBoard.cs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs index cc8d6575..67c10f1e 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs @@ -198,18 +198,21 @@ namespace VocaluxeLib.Menu.SongMenu private void UpdateLength(CSong song) { - float time = CBase.Sound.GetLength(_PreviewSongStream); - if (Math.Abs(song.Finish) > 0.001) - time = song.Finish; - - // The audiobackend is not yet ready to return the length - if (time > 0) + if (song != null) { - time -= song.Start; - var min = (int)Math.Floor(time / 60f); - var sec = (int)(time - min * 60f); - _SongLength.Text = min.ToString("00") + ":" + sec.ToString("00"); - _Length = time; + float time = CBase.Sound.GetLength(_PreviewSongStream); + if (Math.Abs(song.Finish) > 0.001) + time = song.Finish; + + // The audiobackend is not yet ready to return the length + if (time > 0) + { + time -= song.Start; + var min = (int)Math.Floor(time / 60f); + var sec = (int)(time - min * 60f); + _SongLength.Text = min.ToString("00") + ":" + sec.ToString("00"); + _Length = time; + } } }