Merge pull request #5647 from boyu0/bug4324_physicscontact_memory_leak

closed #4324: fix PhysicsContact::generateContactData() memory leak.
This commit is contained in:
minggo 2014-03-10 16:14:53 +08:00
Родитель 66c9323a51 d5031f950a
Коммит 931246b148
1 изменённых файлов: 2 добавлений и 10 удалений

Просмотреть файл

@ -96,6 +96,7 @@ void PhysicsContact::generateContactData()
}
cpArbiter* arb = static_cast<cpArbiter*>(_contactInfo);
CC_SAFE_DELETE(_contactData);
_contactData = new PhysicsContactData();
_contactData->count = cpArbiterGetCount(arb);
for (int i=0; i<_contactData->count && i<PhysicsContactData::POINT_MAX; ++i)
@ -218,16 +219,7 @@ void EventListenerPhysicsContact::onEvent(EventCustom* event)
{
contact->_begin = true;
contact->generateContactData();
// the mask has high priority than _listener->onContactBegin.
// so if the mask test is false, the two bodies won't have collision.
if (ret)
{
ret = onContactBegin(*contact);
}else
{
onContactBegin(*contact);
}
ret = onContactBegin(*contact);
}
contact->setResult(ret);