Skip to content

crash when PhysicsShapeCache::removeAllShapes is called  #5

@smartcompany

Description

@smartcompany

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions