fix memory leak

This commit is contained in:
minggo 2016-05-03 11:22:47 +08:00
parent 5883c7c388
commit fba4bead70
1 changed files with 3 additions and 2 deletions

View File

@ -107,9 +107,7 @@ bool ClippingNode::init()
bool ClippingNode::init(Node *stencil) bool ClippingNode::init(Node *stencil)
{ {
CC_SAFE_RELEASE(_stencil);
setStencil(stencil); setStencil(stencil);
CC_SAFE_RETAIN(_stencil);
return true; return true;
} }
@ -292,6 +290,9 @@ Node* ClippingNode::getStencil() const
void ClippingNode::setStencil(Node *stencil) void ClippingNode::setStencil(Node *stencil)
{ {
if (_stencil == stencil)
return;
#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS #if CC_ENABLE_GC_FOR_NATIVE_OBJECTS
auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine(); auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine();
if (sEngine) if (sEngine)