From 3046aaa361f0fa36095cb85e01c7e7c195a88a73 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Sun, 17 Feb 2013 11:26:52 +0000 Subject: [PATCH] Bugfix: STK would crash if the same kart mesh is used twice (e.g. when just copying a kart folder). Thanks to funto for reporting this. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12499 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/karts/kart_model.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/karts/kart_model.cpp b/src/karts/kart_model.cpp index de2ce7a33..dd4ac069a 100644 --- a/src/karts/kart_model.cpp +++ b/src/karts/kart_model.cpp @@ -169,7 +169,11 @@ KartModel::~KartModel() } } - if(m_is_master && m_mesh != NULL) + m_mesh->drop(); + + // If there is only one copy left, it's the copy in irrlicht's + // mesh cache, so it can be remove. + if(m_is_master && m_mesh != NULL && m_mesh->getReferenceCount()==1) { irr_driver->dropAllTextures(m_mesh); irr_driver->removeMeshFromCache(m_mesh); @@ -351,6 +355,7 @@ bool KartModel::loadModels(const KartProperties &kart_properties) full_path.c_str(), kart_properties.getIdent().c_str()); return false; } + m_mesh->grab(); irr_driver->grabAllTextures(m_mesh); Vec3 min, max;