diff options
| author | lupoDharkael <izhe@hotmail.es> | 2020-04-06 13:22:31 +0200 | 
|---|---|---|
| committer | lupoDharkael <izhe@hotmail.es> | 2020-04-06 13:22:31 +0200 | 
| commit | 1f0f0b8cea138ecda5e2cd36db50f76cd4bbab01 (patch) | |
| tree | 8a884a0a0d4ad9e6cfc149bc809cdfa74241e4a3 | |
| parent | d9a560d7832af7f1ff845ed2b3a81b65741f9abe (diff) | |
NoiseTexture: prevent race condition because of Ref::unref()
| -rw-r--r-- | modules/opensimplex/noise_texture.cpp | 11 | 
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) {  |