From b1f93b2679bc859e818b465fe3b6822f5075d757 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 28 Jun 2016 20:41:47 -0700 Subject: [PATCH] fix: not leak Toggle items Github issue: fixes #13351 --- cocos/2d/CCMenuItem.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/2d/CCMenuItem.cpp b/cocos/2d/CCMenuItem.cpp index 6a6775d78e..9ee4a09be5 100644 --- a/cocos/2d/CCMenuItem.cpp +++ b/cocos/2d/CCMenuItem.cpp @@ -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)