From 54abbc56f0c7d214a1f4db6e7563712b96eb1a5b Mon Sep 17 00:00:00 2001 From: natural-law Date: Tue, 15 Mar 2011 11:59:45 +0800 Subject: [PATCH] [android]fixed #356,modify the parameter type form ccxScopedPtr to std::string *. --- cocos2dx/include/CCLabelTTF.h | 8 ++--- cocos2dx/label_nodes/CCLabelTTF.cpp | 47 +++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/cocos2dx/include/CCLabelTTF.h b/cocos2dx/include/CCLabelTTF.h index e71c582171c0..b92ec28aa289 100644 --- a/cocos2dx/include/CCLabelTTF.h +++ b/cocos2dx/include/CCLabelTTF.h @@ -37,8 +37,8 @@ namespace cocos2d{ class CC_DLL CCLabelTTF : public CCSprite, public CCLabelProtocol { public: - CCLabelTTF() {} - virtual ~CCLabelTTF(){} + CCLabelTTF(); + virtual ~CCLabelTTF(); char * description(); /** creates a CCLabelTTF from a fontname, alignment, dimension and font size */ static CCLabelTTF * labelWithString(const char *label, CCSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize); @@ -59,9 +59,9 @@ namespace cocos2d{ protected: CCSize m_tDimensions; UITextAlignment m_eAlignment; - ccxScopedPtr m_pFontName; + std::string * m_pFontName; float m_fFontSize; - ccxScopedPtr m_pString; + std::string * m_pString; }; } //namespace cocos2d diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index 1d8c84871228..9f7bdc360f0c 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -27,6 +27,28 @@ namespace cocos2d{ // //CCLabelTTF // + CCLabelTTF::CCLabelTTF() + : m_pFontName(NULL) + , m_pString(NULL) + { + } + + CCLabelTTF::~CCLabelTTF() + { + if (m_pFontName) + { + delete m_pFontName; + m_pFontName = NULL; + } + + if (m_pString) + { + delete m_pString; + m_pString = NULL; + } + + } + CCLabelTTF * CCLabelTTF::labelWithString(const char *label, CCSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize) { CCLabelTTF *pRet = new CCLabelTTF(); @@ -57,7 +79,14 @@ namespace cocos2d{ { m_tDimensions = CCSizeMake( dimensions.width * CC_CONTENT_SCALE_FACTOR(), dimensions.height * CC_CONTENT_SCALE_FACTOR() ); m_eAlignment = alignment; - m_pFontName.reset(new std::string(fontName)); + + if (m_pFontName) + { + delete m_pFontName; + m_pFontName = NULL; + } + m_pFontName = new std::string(fontName); + m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR(); this->setString(label); return true; @@ -70,7 +99,14 @@ namespace cocos2d{ if (CCSprite::init()) { m_tDimensions = CCSizeZero; - m_pFontName.reset(new std::string(fontName)); + + if (m_pFontName) + { + delete m_pFontName; + m_pFontName = NULL; + } + m_pFontName = new std::string(fontName); + m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR(); this->setString(label); return true; @@ -79,7 +115,12 @@ namespace cocos2d{ } void CCLabelTTF::setString(const char *label) { - m_pString.reset(new std::string(label)); + if (m_pString) + { + delete m_pString; + m_pString = NULL; + } + m_pString = new std::string(label); CCTexture2D *texture; if( CCSize::CCSizeEqualToSize( m_tDimensions, CCSizeZero ) )