- fixed memory leak with texture creation.

This commit is contained in:
Christoph Oelckers 2018-12-14 01:46:26 +01:00
parent fc5dd17d77
commit 1e844336b9
2 changed files with 25 additions and 2 deletions

View File

@ -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;
}

View File

@ -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