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
|
@ -62,15 +62,21 @@ Data::~Data()
|
||||||
|
|
||||||
Data& Data::operator= (const Data& other)
|
Data& Data::operator= (const Data& other)
|
||||||
{
|
{
|
||||||
CCLOGINFO("In the copy assignment of Data.");
|
if (this != &other)
|
||||||
copy(other._bytes, other._size);
|
{
|
||||||
|
CCLOGINFO("In the copy assignment of Data.");
|
||||||
|
copy(other._bytes, other._size);
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Data& Data::operator= (Data&& other)
|
Data& Data::operator= (Data&& other)
|
||||||
{
|
{
|
||||||
CCLOGINFO("In the move assignment of Data.");
|
if (this != &other)
|
||||||
move(other);
|
{
|
||||||
|
CCLOGINFO("In the move assignment of Data.");
|
||||||
|
move(other);
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -273,14 +273,17 @@ void UniformValue::setMat4(const Mat4& value)
|
||||||
|
|
||||||
UniformValue& UniformValue::operator=(const UniformValue& o)
|
UniformValue& UniformValue::operator=(const UniformValue& o)
|
||||||
{
|
{
|
||||||
_uniform = o._uniform;
|
if (this != &o)
|
||||||
_glprogram = o._glprogram;
|
|
||||||
_type = o._type;
|
|
||||||
_value = o._value;
|
|
||||||
|
|
||||||
if (_uniform->type == GL_SAMPLER_2D)
|
|
||||||
{
|
{
|
||||||
CC_SAFE_RETAIN(_value.tex.texture);
|
_uniform = o._uniform;
|
||||||
|
_glprogram = o._glprogram;
|
||||||
|
_type = o._type;
|
||||||
|
_value = o._value;
|
||||||
|
|
||||||
|
if (_uniform->type == GL_SAMPLER_2D)
|
||||||
|
{
|
||||||
|
CC_SAFE_RETAIN(_value.tex.texture);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue