be safe to handle operator= (#18850)

* 等号赋值函数,先判断this是否不等于other再做赋值

1、CCData那个会闪退
2、CCGLProgramState那个会造成_value.tex.texture泄漏

* replace TAB to  4 SPACE
This commit is contained in:
panzhihao 2018-05-25 09:58:11 +08:00 committed by leda
parent a44e208975
commit cc145cb852
2 changed files with 20 additions and 11 deletions

View File

@ -61,16 +61,22 @@ Data::~Data()
}
Data& Data::operator= (const Data& other)
{
if (this != &other)
{
CCLOGINFO("In the copy assignment of Data.");
copy(other._bytes, other._size);
}
return *this;
}
Data& Data::operator= (Data&& other)
{
if (this != &other)
{
CCLOGINFO("In the move assignment of Data.");
move(other);
}
return *this;
}

View File

@ -272,6 +272,8 @@ void UniformValue::setMat4(const Mat4& value)
}
UniformValue& UniformValue::operator=(const UniformValue& o)
{
if (this != &o)
{
_uniform = o._uniform;
_glprogram = o._glprogram;
@ -282,6 +284,7 @@ UniformValue& UniformValue::operator=(const UniformValue& o)
{
CC_SAFE_RETAIN(_value.tex.texture);
}
}
return *this;
}