From 8e142daa00e18f102a168b296a3b119919e2227f Mon Sep 17 00:00:00 2001 From: hiker Date: Mon, 22 Dec 2014 08:20:19 +1100 Subject: [PATCH] Fix crash when track is not found. --- src/graphics/particle_kind_manager.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/graphics/particle_kind_manager.cpp b/src/graphics/particle_kind_manager.cpp index bb57df73c..dfc6ccf30 100644 --- a/src/graphics/particle_kind_manager.cpp +++ b/src/graphics/particle_kind_manager.cpp @@ -76,7 +76,6 @@ void ParticleKindManager::cleanUpTrackSpecificGfx() ParticleKind* ParticleKindManager::getParticles(const std::string &name) { - Track* t = track_manager->getTrack(race_manager->getTrackName()); std::map::iterator i; i = m_per_track_kinds.find(name); if (i != m_per_track_kinds.end()) @@ -87,9 +86,13 @@ ParticleKind* ParticleKindManager::getParticles(const std::string &name) { try { - ParticleKind* newkind = new ParticleKind(t->getTrackFile(name)); - m_per_track_kinds[name] = newkind; - return newkind; + Track* t = track_manager->getTrack(race_manager->getTrackName()); + if (t) + { + ParticleKind* newkind = new ParticleKind(t->getTrackFile(name)); + m_per_track_kinds[name] = newkind; + return newkind; + } } catch (std::runtime_error& e) {