Bug in joint destruction

KennyUK

01-05-2008 16:22:16

I've been using Slider joints in my game, and have been coming across a bug in OgreNewt's wrapping of them. When I delete a slider joint sometimes Newton will call back to the OgreNewt Slider::newtonCallback method AFTER the OgreNewt slider has been destructed. This causes it to my game to crash.

After looking through the OgreNewt source code I noticed that when a Slider is created it registers a newton callback with this line:

NewtonSliderSetUserCallback( m_joint, newtonCallback );
But this callback is never reset to NULL. So I changed the Slider's destructor to:

Slider::~Slider()
{
NewtonSliderSetUserCallback( m_joint, NULL );
}

and this solved my problem.

I guess all the Basic Joints that use a newton callback (Hinge,Slider & Universal) need to have similar calls in their destructors.

Can the main OgreNewt repository be updated to reflect these fixes?

Cheers