mirror of https://github.com/axmolengine/axmol.git
Make CustomCommand safe copyable and moveable
This commit is contained in:
parent
aa5fc9dc0f
commit
93b39601f9
|
@ -41,6 +41,44 @@ CustomCommand::~CustomCommand()
|
||||||
CC_SAFE_RELEASE(_indexBuffer);
|
CC_SAFE_RELEASE(_indexBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CustomCommand::CustomCommand(const CustomCommand& rhs)
|
||||||
|
{
|
||||||
|
this->copyAssign(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomCommand::CustomCommand(CustomCommand&& rhs)
|
||||||
|
{
|
||||||
|
this->moveAssign(std::move(rhs));
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomCommand& CustomCommand::operator=(const CustomCommand& rhs)
|
||||||
|
{
|
||||||
|
this->copyAssign(rhs);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
CustomCommand& CustomCommand::operator=(CustomCommand&& rhs)
|
||||||
|
{
|
||||||
|
this->moveAssign(std::move(rhs));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomCommand::copyAssign(const CustomCommand& rhs)
|
||||||
|
{
|
||||||
|
if (this != &rhs) {
|
||||||
|
memcpy(this, &rhs, sizeof(rhs));
|
||||||
|
CC_SAFE_RETAIN(_vertexBuffer);
|
||||||
|
CC_SAFE_RETAIN(_indexBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomCommand::moveAssign(CustomCommand&& rhs)
|
||||||
|
{
|
||||||
|
if (this != &rhs) {
|
||||||
|
memcpy(this, &rhs, sizeof(rhs));
|
||||||
|
rhs._vertexBuffer = rhs._indexBuffer = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CustomCommand::init(float depth, const cocos2d::Mat4 &modelViewTransform, unsigned int flags)
|
void CustomCommand::init(float depth, const cocos2d::Mat4 &modelViewTransform, unsigned int flags)
|
||||||
{
|
{
|
||||||
RenderCommand::init(depth, modelViewTransform, flags);
|
RenderCommand::init(depth, modelViewTransform, flags);
|
||||||
|
|
|
@ -68,10 +68,18 @@ public:
|
||||||
|
|
||||||
/**Constructor.*/
|
/**Constructor.*/
|
||||||
CustomCommand();
|
CustomCommand();
|
||||||
|
CustomCommand(const CustomCommand& rhs);
|
||||||
|
CustomCommand(CustomCommand&& rhs);
|
||||||
/**Destructor.*/
|
/**Destructor.*/
|
||||||
~CustomCommand();
|
~CustomCommand();
|
||||||
|
|
||||||
|
|
||||||
|
CustomCommand& operator=(const CustomCommand& rhs);
|
||||||
|
CustomCommand& operator=(CustomCommand&& rhs);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void copyAssign(const CustomCommand& rhs);
|
||||||
|
void moveAssign(CustomCommand&& rhs);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
TODO: should remove it.
|
TODO: should remove it.
|
||||||
|
|
Loading…
Reference in New Issue