diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index 9beeea2229..0efd2b7498 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -305,10 +305,12 @@ CCNode * CCScrollView::getContainer() 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); - - if (!pContainer) return; - this->m_pContainer = pContainer; this->m_pContainer->ignoreAnchorPointForPosition(false);