diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp index ec67030a659..2018f90e9fb 100644 --- a/modules/opensimplex/noise_texture.cpp +++ b/modules/opensimplex/noise_texture.cpp @@ -137,14 +137,19 @@ void NoiseTexture::_queue_update() { Ref NoiseTexture::_generate_texture() { - if (noise.is_null()) return Ref(); + // Prevent memdelete due to unref() on other thread. + Ref ref_noise = noise; + + if (ref_noise.is_null()) { + return Ref(); + } Ref image; if (seamless) { - image = noise->get_seamless_image(size.x); + image = ref_noise->get_seamless_image(size.x); } else { - image = noise->get_image(size.x, size.y); + image = ref_noise->get_image(size.x, size.y); } if (as_normalmap) {