|
From: rainbyte <rai...@us...> - 2012-07-17 10:46:30
|
Author: Lasse Karkkainen <tro...@tr...>
Date: Sat Feb 11 08:51:26 2012 +0200
Make Songs::currentPtr return NULL instead of segfaulting if there are no songs.
---
game/songs.hh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/game/songs.hh b/game/songs.hh
index d403139..70b5a2a 100644
--- a/game/songs.hh
+++ b/game/songs.hh
@@ -46,7 +46,7 @@ class Songs: boost::noncopyable {
/// sets margins for animation
void setAnimMargins(double left, double right) { math_cover.setMargins(left, right); }
/// @return current song
- boost::shared_ptr<Song> currentPtr() { return m_filtered[math_cover.getTarget()]; }
+ boost::shared_ptr<Song> currentPtr() { return m_filtered.empty() ? boost::shared_ptr<Song>() : m_filtered[math_cover.getTarget()]; }
/// @return current song
Song& current() { return *m_filtered[math_cover.getTarget()]; }
/// @return current Song
|