free-language / box2d

Automatically exported from code.google.com/p/box2d
0 stars 0 forks source link

Check if body exists before removing it #147

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a body and hold a reference to it in game
2. Remove it from the engine
3. Remove it from the engine again

What is the expected output? What do you see instead?
You can't do that because it already has been removed. Instead I end up inside 
b2Island.Add() with the assert:

b2Assert(m_bodyCount < m_bodyCapacity);

What version of the product are you using?
Box2D rev 112 from new source control.

Could be fixed by checking the body linked list for the body before removing 
it. The code should only run when in debugging mode.

Original issue reported on code.google.com by Qvist...@gmail.com on 7 Aug 2010 at 10:01

GoogleCodeExporter commented 9 years ago
This is a typical programming problem. The solution is the nullify your 
pointers after you destroy them.

Original comment by erinca...@gmail.com on 24 Aug 2010 at 6:39