Fix memory leak when using CurveTexture.set_texture_mode

This commit is contained in:
Haoyu Qiu 2021-11-01 18:57:59 +08:00
parent efbbd14af3
commit 10818cfc10
3 changed files with 4 additions and 1 deletions

View File

@ -625,6 +625,8 @@ void RasterizerStorageGLES3::texture_replace(RID p_texture, RID p_by_texture) {
for (int n = 0; n < tex_from->images.size(); n++) {
texture_set_data(p_texture, tex_from->images[n], n);
}
free(p_by_texture);
}
bool RasterizerStorageGLES3::_is_main_thread() {

View File

@ -1503,6 +1503,7 @@ Ref<Curve> CurveTexture::get_curve() const {
}
void CurveTexture::set_texture_mode(TextureMode p_mode) {
ERR_FAIL_COND(p_mode < TEXTURE_MODE_RGB || p_mode > TEXTURE_MODE_RED);
if (texture_mode == p_mode) {
return;
}

View File

@ -258,7 +258,7 @@ public:
Ref<Image> texture_2d_layer_get(RID p_texture, int p_layer) const override { return Ref<Image>(); }
Vector<Ref<Image>> texture_3d_get(RID p_texture) const override { return Vector<Ref<Image>>(); }
void texture_replace(RID p_texture, RID p_by_texture) override {}
void texture_replace(RID p_texture, RID p_by_texture) override { free(p_by_texture); }
void texture_set_size_override(RID p_texture, int p_width, int p_height) override {}
void texture_set_path(RID p_texture, const String &p_path) override {}