mirror of https://github.com/axmolengine/axmol.git
Fixed a memory leak in CCLabelBMFont.cpp.
This commit is contained in:
parent
5ad6c38500
commit
22052db4bd
|
@ -42,6 +42,9 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only)
|
||||||
#include "support/data_support/uthash.h"
|
#include "support/data_support/uthash.h"
|
||||||
#include "CCDirector.h"
|
#include "CCDirector.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
typedef struct _FontDefHashElement
|
typedef struct _FontDefHashElement
|
||||||
|
@ -788,6 +791,7 @@ bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, f
|
||||||
m_pAlignment = alignment;
|
m_pAlignment = alignment;
|
||||||
m_tImageOffset = imageOffset;
|
m_tImageOffset = imageOffset;
|
||||||
m_fWidth = width;
|
m_fWidth = width;
|
||||||
|
CC_SAFE_DELETE_ARRAY(m_sString);
|
||||||
m_sString = cc_utf8_from_cstr(theString);
|
m_sString = cc_utf8_from_cstr(theString);
|
||||||
m_cOpacity = 255;
|
m_cOpacity = 255;
|
||||||
m_tColor = ccWHITE;
|
m_tColor = ccWHITE;
|
||||||
|
@ -953,11 +957,12 @@ void CCLabelBMFont::setString(const char *newString, bool fromUpdate)
|
||||||
{
|
{
|
||||||
if (fromUpdate)
|
if (fromUpdate)
|
||||||
{
|
{
|
||||||
|
CC_SAFE_DELETE_ARRAY(m_sString);
|
||||||
m_sString = cc_utf8_from_cstr(newString);
|
m_sString = cc_utf8_from_cstr(newString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_sString_initial = std::string(newString);
|
m_sString_initial = newString;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateString(fromUpdate);
|
updateString(fromUpdate);
|
||||||
|
@ -1078,8 +1083,6 @@ void CCLabelBMFont::setAnchorPoint(const CCPoint& point)
|
||||||
// LabelBMFont - Alignment
|
// LabelBMFont - Alignment
|
||||||
void CCLabelBMFont::updateLabel()
|
void CCLabelBMFont::updateLabel()
|
||||||
{
|
{
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
this->setString(m_sString_initial.c_str(), true);
|
this->setString(m_sString_initial.c_str(), true);
|
||||||
|
|
||||||
if (m_fWidth > 0)
|
if (m_fWidth > 0)
|
||||||
|
@ -1240,7 +1243,7 @@ void CCLabelBMFont::updateLabel()
|
||||||
|
|
||||||
str_new[size] = 0;
|
str_new[size] = 0;
|
||||||
|
|
||||||
delete[] m_sString;
|
CC_SAFE_DELETE_ARRAY(m_sString);
|
||||||
m_sString = str_new;
|
m_sString = str_new;
|
||||||
updateString(true);
|
updateString(true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue