From b92733c402d8e55680d88f5f5f019986af055fc7 Mon Sep 17 00:00:00 2001 From: Vincent Yang Date: Tue, 28 Jul 2015 11:38:21 +0800 Subject: [PATCH] Add items as protected children. --- cocos/ui/UIRichText.cpp | 6 +++--- .../CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cocos/ui/UIRichText.cpp b/cocos/ui/UIRichText.cpp index 7fac871a00..c32489b8b1 100644 --- a/cocos/ui/UIRichText.cpp +++ b/cocos/ui/UIRichText.cpp @@ -178,7 +178,7 @@ void RichText::formatText() { if (_formatTextDirty) { - this->removeAllChildren(); + this->removeAllProtectedChildren(); _elementRenders.clear(); if (_ignoreSize) { @@ -353,7 +353,7 @@ void RichText::formarRenderers() Node* l = row->at(j); l->setAnchorPoint(Vec2::ZERO); l->setPosition(nextPosX, 0.0f); - this->addChild(l, 1); + this->addProtectedChild(l, 1); Size iSize = l->getContentSize(); newContentSizeWidth += iSize.width; newContentSizeHeight = MAX(newContentSizeHeight, iSize.height); @@ -391,7 +391,7 @@ void RichText::formarRenderers() Node* l = row->at(j); l->setAnchorPoint(Vec2::ZERO); l->setPosition(nextPosX, nextPosY); - this->addChild(l, 1); + this->addProtectedChild(l, 1); nextPosX += l->getContentSize().width; } } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp index 8efb7e33fd..93d0d11661 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp @@ -93,6 +93,9 @@ bool UIRichTextTest::init() _widget->addChild(_richText); + // test remove all children, this call won't effect the test + _richText->removeAllChildren(); + return true; } return false;