From 8b92b8407640fb93cb668c1c0d5cdbf9fb33ec04 Mon Sep 17 00:00:00 2001 From: auria Date: Fri, 13 May 2011 01:33:22 +0000 Subject: [PATCH] Fixed crash when textures are not found git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8561 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/graphics/material.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/graphics/material.cpp b/src/graphics/material.cpp index 019c428a4..fb319f868 100644 --- a/src/graphics/material.cpp +++ b/src/graphics/material.cpp @@ -255,6 +255,8 @@ void Material::install(bool is_full_path) m_texture = irr_driver->getTexture(full_path, isPreMul(), isPreDiv()); + if (m_texture == NULL) return; + // now set the name to the basename, so that all tests work as expected m_texname = StringUtils::getBasename(m_texname); @@ -277,10 +279,13 @@ void Material::install(bool is_full_path) //----------------------------------------------------------------------------- Material::~Material() { - assert(m_texture); - m_texture->drop(); - if(m_texture->getReferenceCount()==1) - irr_driver->removeTexture(m_texture); + if (m_texture != NULL) + { + m_texture->drop(); + if(m_texture->getReferenceCount()==1) + irr_driver->removeTexture(m_texture); + } + // If a special sfx is installed (that isn't part of stk itself), the // entry needs to be removed from the sfx_manager's mapping, since other // tracks might use the same name.