diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 9c5f7b894..01bfdf1b6 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -335,7 +335,7 @@ bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, i if (!tex->isHardwareCanvas()) { - texbuffer = tex->CreateTexBuffer(translation, flags | CTF_ProcessData); + texbuffer = std::move(tex->CreateTexBuffer(translation, flags | CTF_ProcessData)); w = texbuffer.mWidth; h = texbuffer.mHeight; } diff --git a/src/textures/textures.h b/src/textures/textures.h index 90d12c0c2..d25026634 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -247,10 +247,33 @@ struct FTextureBuffer int mHeight = 0; uint64_t mContentId = 0; // unique content identifier. (Two images created from the same image source with the same settings will return the same value.) - FTextureBuffer() + FTextureBuffer() = default; + + ~FTextureBuffer() { if (mBuffer) delete[] mBuffer; } + + FTextureBuffer(const FTextureBuffer &other) = delete; + FTextureBuffer(FTextureBuffer &&other) + { + mBuffer = other.mBuffer; + mWidth = other.mWidth; + mHeight = other.mHeight; + mContentId = other.mContentId; + other.mBuffer = nullptr; + } + + FTextureBuffer& operator=(FTextureBuffer &&other) + { + mBuffer = other.mBuffer; + mWidth = other.mWidth; + mHeight = other.mHeight; + mContentId = other.mContentId; + other.mBuffer = nullptr; + return *this; + } + }; // Base texture class