PhysicsEditor-Loaders icon indicating copy to clipboard operation
PhysicsEditor-Loaders copied to clipboard

crash when PhysicsShapeCache::removeAllShapes is called

Open smartcompany opened this issue 8 years ago • 0 comments

PhysicsShapeCache code has some issue when BodyDef is removed I think below definition has an issue Map<std::string, BodyDef *> bodyDefs;

so i change this to std::map<std::string, BodyDef *> bodyDefs; and change safe delete function

bool PhysicsShapeCache::safeDeleteBodyDef(BodyDef *bodyDef)
{
    for (auto fixturedate : bodyDef->fixtures)
    {
        for (auto polygon : fixturedate->polygons)
        {
            CC_SAFE_DELETE_ARRAY(polygon->vertices);
        }
        fixturedate->polygons.clear();
    }
    bodyDef->fixtures.clear();
    bodyDef->release();  // insert release code here
    return true;
}

it runs well

smartcompany avatar Mar 04 '16 19:03 smartcompany