diff --git a/cocos/base/CCData.cpp b/cocos/base/CCData.cpp index 40e10777dc..5b2a1189a9 100644 --- a/cocos/base/CCData.cpp +++ b/cocos/base/CCData.cpp @@ -62,15 +62,21 @@ Data::~Data() Data& Data::operator= (const Data& other) { - CCLOGINFO("In the copy assignment of Data."); - copy(other._bytes, other._size); + if (this != &other) + { + CCLOGINFO("In the copy assignment of Data."); + copy(other._bytes, other._size); + } return *this; } Data& Data::operator= (Data&& other) { - CCLOGINFO("In the move assignment of Data."); - move(other); + if (this != &other) + { + CCLOGINFO("In the move assignment of Data."); + move(other); + } return *this; } diff --git a/cocos/renderer/CCGLProgramState.cpp b/cocos/renderer/CCGLProgramState.cpp index 571665d99f..13ab9e6c0e 100644 --- a/cocos/renderer/CCGLProgramState.cpp +++ b/cocos/renderer/CCGLProgramState.cpp @@ -273,14 +273,17 @@ void UniformValue::setMat4(const Mat4& value) UniformValue& UniformValue::operator=(const UniformValue& o) { - _uniform = o._uniform; - _glprogram = o._glprogram; - _type = o._type; - _value = o._value; - - if (_uniform->type == GL_SAMPLER_2D) + if (this != &o) { - 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; }