Merge pull request #2367 from dumganhar/iss1862-setContainer

fixed #1862: CCScrollView::setContainer may cause dangling pointer when NULL is passed into.
This commit is contained in:
James Chen 2013-04-14 18:57:13 -07:00
commit a06d2c44c1
1 changed files with 5 additions and 3 deletions

View File

@ -305,10 +305,12 @@ CCNode * CCScrollView::getContainer()
void CCScrollView::setContainer(CCNode * pContainer) void CCScrollView::setContainer(CCNode * pContainer)
{ {
// Make sure that 'm_pContainer' has a non-NULL value since there are
// lots of logic that use 'm_pContainer'.
if (NULL == pContainer)
return;
this->removeAllChildrenWithCleanup(true); this->removeAllChildrenWithCleanup(true);
if (!pContainer) return;
this->m_pContainer = pContainer; this->m_pContainer = pContainer;
this->m_pContainer->ignoreAnchorPointForPosition(false); this->m_pContainer->ignoreAnchorPointForPosition(false);