Merge pull request #15999 from ricardoquesada/issue13351

fix: not leak Toggle items
This commit is contained in:
Ricardo Quesada 2016-06-28 21:40:10 -07:00 committed by GitHub
commit 935c60c552
1 changed files with 2 additions and 0 deletions

View File

@ -789,6 +789,7 @@ MenuItemToggle * MenuItemToggle::createWithTarget(Ref* target, SEL_MenuHandler s
{
MenuItemToggle *ret = new (std::nothrow) MenuItemToggle();
ret->MenuItem::initWithCallback(std::bind(selector, target, std::placeholders::_1));
ret->autorelease();
#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS
auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine();
if (sEngine)
@ -812,6 +813,7 @@ MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callba
{
MenuItemToggle *ret = new (std::nothrow) MenuItemToggle();
ret->MenuItem::initWithCallback(callback);
ret->autorelease();
#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS
auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine();
if (sEngine)