You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
NoiseTexture: prevent race condition because of Ref::unref()
This commit is contained in:
@@ -137,14 +137,19 @@ void NoiseTexture::_queue_update() {
|
|||||||
|
|
||||||
Ref<Image> NoiseTexture::_generate_texture() {
|
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;
|
Ref<Image> image;
|
||||||
|
|
||||||
if (seamless) {
|
if (seamless) {
|
||||||
image = noise->get_seamless_image(size.x);
|
image = ref_noise->get_seamless_image(size.x);
|
||||||
} else {
|
} else {
|
||||||
image = noise->get_image(size.x, size.y);
|
image = ref_noise->get_image(size.x, size.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (as_normalmap) {
|
if (as_normalmap) {
|
||||||
|
|||||||
Reference in New Issue
Block a user