From f1b87ef0e9682a48701abc07adcabc7ec24fe6ca Mon Sep 17 00:00:00 2001 From: walzer Date: Thu, 4 Oct 2012 09:03:22 +0800 Subject: [PATCH] fix bugs in CCDictionary::objectForKey(int/string) --- cocos2dx/cocoa/CCDictionary.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cocos2dx/cocoa/CCDictionary.cpp b/cocos2dx/cocoa/CCDictionary.cpp index 64a0c11fd6..9bd909e4f3 100644 --- a/cocos2dx/cocoa/CCDictionary.cpp +++ b/cocos2dx/cocoa/CCDictionary.cpp @@ -93,10 +93,11 @@ CCObject* CCDictionary::objectForKey(const std::string& key) { if (m_eDictType != kCCDictStr) { - CCAssert(m_eDictType == kCCDictStr, "this dictionary does not use string as key."); return NULL; } + CCAssert(m_eDictType == kCCDictStr, "this dictionary does not use string as key."); + CCObject* pRetObject = NULL; CCDictElement *pElement = NULL; HASH_FIND_STR(m_pElements, key.c_str(), pElement); @@ -111,10 +112,11 @@ CCObject* CCDictionary::objectForKey(int key) { if (m_eDictType != kCCDictInt) { - CCAssert(m_eDictType == kCCDictInt, "this dictionary does not use integer as key."); return NULL; } + CCAssert(m_eDictType == kCCDictInt, "this dictionary does not use integer as key."); + CCObject* pRetObject = NULL; CCDictElement *pElement = NULL; HASH_FIND_INT(m_pElements, &key, pElement);