summaryrefslogtreecommitdiff
path: root/modules/opensimplex/noise_texture.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-04-10 11:52:10 +0200
committerGitHub <noreply@github.com>2020-04-10 11:52:10 +0200
commit56bee78b6e2ddb9504a9fd2b40526ee9d1ecb14c (patch)
tree383701a8eb4c6a2699e1baad66f125b7b130b2eb /modules/opensimplex/noise_texture.cpp
parenta152ef9a10d7e37f6150f5c45e24090047edf21f (diff)
parent1f0f0b8cea138ecda5e2cd36db50f76cd4bbab01 (diff)
Merge pull request #37629 from lupoDharkael/noise-unref
NoiseTexture: prevent race condition because of Ref::unref()
Diffstat (limited to 'modules/opensimplex/noise_texture.cpp')
-rw-r--r--modules/opensimplex/noise_texture.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp
index ec67030a65..2018f90e9f 100644
--- a/modules/opensimplex/noise_texture.cpp
+++ b/modules/opensimplex/noise_texture.cpp
@@ -137,14 +137,19 @@ void NoiseTexture::_queue_update() {
Ref<Image> NoiseTexture::_generate_texture() {
- if (noise.is_null()) return Ref<Image>();
+ // Prevent memdelete due to unref() on other thread.
+ Ref<OpenSimplexNoise> ref_noise = noise;
+
+ if (ref_noise.is_null()) {
+ return Ref<Image>();
+ }
Ref<Image> 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) {