From fba4bead704497f7c111746f703fbef56c35bec2 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 3 May 2016 11:22:47 +0800 Subject: [PATCH] fix memory leak --- cocos/2d/CCClippingNode.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index b5229c8bd4..d7e4b7fa25 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -107,9 +107,7 @@ bool ClippingNode::init() bool ClippingNode::init(Node *stencil) { - CC_SAFE_RELEASE(_stencil); setStencil(stencil); - CC_SAFE_RETAIN(_stencil); return true; } @@ -292,6 +290,9 @@ Node* ClippingNode::getStencil() const void ClippingNode::setStencil(Node *stencil) { + if (_stencil == stencil) + return; + #if CC_ENABLE_GC_FOR_NATIVE_OBJECTS auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine(); if (sEngine)