From 677cf0035553e06606ad4799022cda19f92b328c Mon Sep 17 00:00:00 2001 From: yinkaile Date: Mon, 11 Nov 2013 15:29:24 +0800 Subject: [PATCH] fix compiler warning --- .../editor-support/cocostudio/CCArmature.cpp | 2 +- cocos/editor-support/cocostudio/CCBone.cpp | 19 +++++++++++-------- cocos/editor-support/cocostudio/CCBone.h | 6 ++++-- .../cocostudio/CCDisplayManager.cpp | 10 +++++----- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 0e19914954..b09922ff70 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -289,7 +289,7 @@ void Armature::removeBone(Bone *bone, bool recursion) CCASSERT(bone != nullptr, "bone must be added to the bone dictionary!"); bone->setArmature(nullptr); - bone->removeFromParent(); + bone->removeFromParent(recursion); if (_topBoneList->containsObject(bone)) { diff --git a/cocos/editor-support/cocostudio/CCBone.cpp b/cocos/editor-support/cocostudio/CCBone.cpp index 17541e2e78..cbd4544120 100644 --- a/cocos/editor-support/cocostudio/CCBone.cpp +++ b/cocos/editor-support/cocostudio/CCBone.cpp @@ -322,16 +322,19 @@ void Bone::addChildBone(Bone *child) } } -void Bone::removeChildBone(Bone *bone) +void Bone::removeChildBone(Bone *bone, bool recursion) { if (_children && _children->getIndexOfObject(bone) != UINT_MAX ) { - Array *ccbones = bone->_children; - - for(auto object : *ccbones) + if(recursion) { - Bone *ccBone = (Bone *)object; - bone->removeChildBone(ccBone); + Array *ccbones = bone->_children; + + for(auto object : *ccbones) + { + Bone *ccBone = (Bone *)object; + bone->removeChildBone(ccBone, recursion); + } } bone->setParentBone(nullptr); @@ -342,11 +345,11 @@ void Bone::removeChildBone(Bone *bone) } } -void Bone::removeFromParent() +void Bone::removeFromParent(bool recursion) { if (nullptr != _parentBone) { - _parentBone->removeChildBone(this); + _parentBone->removeChildBone(this, recursion); } } diff --git a/cocos/editor-support/cocostudio/CCBone.h b/cocos/editor-support/cocostudio/CCBone.h index 17dc334c34..8a603c1ad3 100644 --- a/cocos/editor-support/cocostudio/CCBone.h +++ b/cocos/editor-support/cocostudio/CCBone.h @@ -112,16 +112,18 @@ public: */ Bone *getParentBone(); + using Node::removeFromParent; /** * Remove itself from its parent. + * @param recursion whether or not to remove childBone's display */ - void removeFromParent(); + void removeFromParent(bool recursion); /** * Removes a child Bone * @param bone the bone you want to remove */ - void removeChildBone(Bone *bone); + void removeChildBone(Bone *bone, bool recursion); void update(float delta) override; diff --git a/cocos/editor-support/cocostudio/CCDisplayManager.cpp b/cocos/editor-support/cocostudio/CCDisplayManager.cpp index 6bcf7eaff3..3c502f2fe7 100644 --- a/cocos/editor-support/cocostudio/CCDisplayManager.cpp +++ b/cocos/editor-support/cocostudio/CCDisplayManager.cpp @@ -146,13 +146,13 @@ void DisplayManager::addDisplay(Node *display, int index) for (int i = _decoDisplayList->count()-2; i>=0; i--) { - DecorativeDisplay *dd = static_cast(_decoDisplayList->objectAtIndex(i)); - SpriteDisplayData *spriteDisplayData = static_cast(dd->getDisplayData()); - if (spriteDisplayData) + DecorativeDisplay *dd = static_cast(_decoDisplayList->getObjectAtIndex(i)); + SpriteDisplayData *sdd = static_cast(dd->getDisplayData()); + if (sdd) { find = true; - skin->setSkinData(spriteDisplayData->skinData); - static_cast(displayData)->skinData = spriteDisplayData->skinData; + skin->setSkinData(sdd->skinData); + static_cast(displayData)->skinData = sdd->skinData; break; } }