From 16afe5b616873a8c2be4b151b97b116df034460c Mon Sep 17 00:00:00 2001 From: walzer Date: Tue, 2 Oct 2012 22:30:27 +0800 Subject: [PATCH] fix bugs in CCDictionary & platform/win32/CCImage.cpp::setFont, according to BitWave's codereview. --- cocos2dx/cocoa/CCDictionary.cpp | 14 ++++++++++---- cocos2dx/platform/win32/CCImage.cpp | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cocos2dx/cocoa/CCDictionary.cpp b/cocos2dx/cocoa/CCDictionary.cpp index 2265d85540..64a0c11fd6 100644 --- a/cocos2dx/cocoa/CCDictionary.cpp +++ b/cocos2dx/cocoa/CCDictionary.cpp @@ -91,8 +91,11 @@ CCArray* CCDictionary::allKeysForObject(CCObject* object) CCObject* CCDictionary::objectForKey(const std::string& key) { - if (m_eDictType == kCCDictUnknown && m_eDictType == kCCDictUnknown) return NULL; - CCAssert(m_eDictType == kCCDictStr, "this dictionary does not use string as key."); + if (m_eDictType != kCCDictStr) + { + CCAssert(m_eDictType == kCCDictStr, "this dictionary does not use string as key."); + return NULL; + } CCObject* pRetObject = NULL; CCDictElement *pElement = NULL; @@ -106,8 +109,11 @@ CCObject* CCDictionary::objectForKey(const std::string& key) CCObject* CCDictionary::objectForKey(int key) { - if (m_eDictType == kCCDictUnknown && m_eDictType == kCCDictUnknown) return NULL; - CCAssert(m_eDictType == kCCDictInt, "this dictionary does not use integer as key."); + if (m_eDictType != kCCDictInt) + { + CCAssert(m_eDictType == kCCDictInt, "this dictionary does not use integer as key."); + return NULL; + } CCObject* pRetObject = NULL; CCDictElement *pElement = NULL; diff --git a/cocos2dx/platform/win32/CCImage.cpp b/cocos2dx/platform/win32/CCImage.cpp index 27d0b69468..c339963aa0 100644 --- a/cocos2dx/platform/win32/CCImage.cpp +++ b/cocos2dx/platform/win32/CCImage.cpp @@ -126,8 +126,8 @@ public: } GetObjectA(m_hFont, sizeof(tOldFont), &tOldFont); - if (tOldFont.lfHeight == tNewFont.lfHeight - && ! strcpy(tOldFont.lfFaceName, tNewFont.lfFaceName)) + if (tOldFont.lfHeight == tNewFont.lfHeight && + !strcmp(tOldFont.lfFaceName, tNewFont.lfFaceName)) { // already has the font bRet = true;