Added grab/drop to avoid that the animated scene node of

which a copy is used is not accidentally deleted.
Also initialised m_animated_node with zero to handle
incorrect usages of the kart model.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6094 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-09-20 23:27:49 +00:00
parent adffdc4eaa
commit 357483da51

View File

@ -121,7 +121,9 @@ void KartModel::loadInfo(const XMLNode &node)
*/
KartModel::~KartModel()
{
m_animated_node->setAnimationEndCallback(NULL);
if(m_animated_node)
m_animated_node->setAnimationEndCallback(NULL);
m_animated_node->drop();
for(unsigned int i=0; i<4; i++)
{
if(m_wheel_node[i])
@ -155,6 +157,7 @@ KartModel* KartModel::makeCopy()
km->m_model_filename = m_model_filename;
km->m_animation_speed = m_animation_speed;
km->m_current_animation = AF_DEFAULT;
km->m_animated_node = NULL;
for(unsigned int i=0; i<4; i++)
{
km->m_wheel_model[i] = m_wheel_model[i];
@ -186,6 +189,7 @@ void KartModel::attachModel(scene::ISceneNode **node)
*node = irr_driver->addAnimatedMesh(m_mesh);
m_animated_node = static_cast<scene::IAnimatedMeshSceneNode*>(*node);
m_animated_node->setLoopMode(false);
m_animated_node->grab();
}
else
{