mirror of https://github.com/axmolengine/axmol.git
Merge pull request #14016 from xiaofeng11/v3
Fix quickly click mouse in "41:Node:Physics -> 6:joints" in cpp-test may cause program crash
This commit is contained in:
commit
2dbe0c1a90
|
@ -580,15 +580,19 @@ void PhysicsWorld::removeJoint(PhysicsJoint* joint, bool destroy)
|
|||
}
|
||||
|
||||
joint->_destoryMark = destroy;
|
||||
|
||||
bool removedFromDelayAdd = false;
|
||||
auto it = std::find(_delayAddJoints.begin(), _delayAddJoints.end(), joint);
|
||||
if (it != _delayAddJoints.end())
|
||||
{
|
||||
_delayAddJoints.erase(it);
|
||||
removedFromDelayAdd = true;
|
||||
}
|
||||
|
||||
if (cpSpaceIsLocked(_cpSpace))
|
||||
{
|
||||
auto it = std::find(_delayAddJoints.begin(), _delayAddJoints.end(), joint);
|
||||
if (it != _delayAddJoints.end())
|
||||
{
|
||||
_delayAddJoints.erase(it);
|
||||
if (removedFromDelayAdd)
|
||||
return;
|
||||
}
|
||||
|
||||
if (std::find(_delayRemoveJoints.rbegin(), _delayRemoveJoints.rend(), joint) == _delayRemoveJoints.rend())
|
||||
{
|
||||
_delayRemoveJoints.push_back(joint);
|
||||
|
@ -647,11 +651,9 @@ void PhysicsWorld::addJoint(PhysicsJoint* joint)
|
|||
{
|
||||
if (joint)
|
||||
{
|
||||
if (joint->getWorld() && joint->getWorld() != this)
|
||||
{
|
||||
joint->removeFormWorld();
|
||||
}
|
||||
CCASSERT(joint->getWorld() == nullptr, "Can not add joint already add to other world!");
|
||||
|
||||
joint->_world = this;
|
||||
auto it = std::find(_delayRemoveJoints.begin(), _delayRemoveJoints.end(), joint);
|
||||
if (it != _delayRemoveJoints.end())
|
||||
{
|
||||
|
|
|
@ -430,7 +430,7 @@ void ParticleMainScene::updateTitle()
|
|||
////////////////////////////////////////////////////////
|
||||
std::string ParticlePerformTest1::title() const
|
||||
{
|
||||
char str[20] = {0};
|
||||
char str[32] = {0};
|
||||
sprintf(str, "A (%d) size=%d", subtestNumber, particleSize);
|
||||
std::string strRet = str;
|
||||
return strRet;
|
||||
|
|
Loading…
Reference in New Issue