diff --git a/cocos/base/CCMap.h b/cocos/base/CCMap.h index 1c8c53ef0a..8144a9d90e 100644 --- a/cocos/base/CCMap.h +++ b/cocos/base/CCMap.h @@ -274,9 +274,9 @@ public: void insert(const K& key, V object) { CCASSERT(object != nullptr, "Object is nullptr!"); + object->retain(); erase(key); _data.insert(std::make_pair(key, object)); - object->retain(); } /** @@ -308,7 +308,6 @@ public: _data.erase(iter); return 1; } - return 0; }