mirror of https://github.com/axmolengine/axmol.git
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:
parent
a44e208975
commit
cc145cb852
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue