From 90a0c06631b785425184320613302a4014786b9e Mon Sep 17 00:00:00 2001 From: Alex Threlfo Date: Fri, 20 Dec 2024 15:50:27 +1100 Subject: [PATCH] Fix crash when duplicating Decal or Light3D nodes Co-authored-by: Jayden Sipe --- scene/3d/decal.cpp | 16 ++++++++-------- scene/3d/light_3d.cpp | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/scene/3d/decal.cpp b/scene/3d/decal.cpp index df987a5ed02..82d72f876d9 100644 --- a/scene/3d/decal.cpp +++ b/scene/3d/decal.cpp @@ -46,14 +46,14 @@ void Decal::set_texture(DecalTexture p_type, const Ref &p_texture) { RID texture_rid = p_texture.is_valid() ? p_texture->get_rid() : RID(); #ifdef DEBUG_ENABLED - if ( - p_texture->is_class("AnimatedTexture") || - p_texture->is_class("AtlasTexture") || - p_texture->is_class("CameraTexture") || - p_texture->is_class("CanvasTexture") || - p_texture->is_class("MeshTexture") || - p_texture->is_class("Texture2DRD") || - p_texture->is_class("ViewportTexture")) { + if (p_texture.is_valid() && + (p_texture->is_class("AnimatedTexture") || + p_texture->is_class("AtlasTexture") || + p_texture->is_class("CameraTexture") || + p_texture->is_class("CanvasTexture") || + p_texture->is_class("MeshTexture") || + p_texture->is_class("Texture2DRD") || + p_texture->is_class("ViewportTexture"))) { WARN_PRINT(vformat("%s cannot be used as a Decal texture (%s). As a workaround, assign the value returned by %s's `get_image()` instead.", p_texture->get_class(), get_path(), p_texture->get_class())); } #endif diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp index d1eca0f405a..f4e7815e03f 100644 --- a/scene/3d/light_3d.cpp +++ b/scene/3d/light_3d.cpp @@ -202,14 +202,14 @@ void Light3D::set_projector(const Ref &p_texture) { RID tex_id = projector.is_valid() ? projector->get_rid() : RID(); #ifdef DEBUG_ENABLED - if ( - p_texture->is_class("AnimatedTexture") || - p_texture->is_class("AtlasTexture") || - p_texture->is_class("CameraTexture") || - p_texture->is_class("CanvasTexture") || - p_texture->is_class("MeshTexture") || - p_texture->is_class("Texture2DRD") || - p_texture->is_class("ViewportTexture")) { + if (p_texture.is_valid() && + (p_texture->is_class("AnimatedTexture") || + p_texture->is_class("AtlasTexture") || + p_texture->is_class("CameraTexture") || + p_texture->is_class("CanvasTexture") || + p_texture->is_class("MeshTexture") || + p_texture->is_class("Texture2DRD") || + p_texture->is_class("ViewportTexture"))) { WARN_PRINT(vformat("%s cannot be used as a Light3D projector texture (%s). As a workaround, assign the value returned by %s's `get_image()` instead.", p_texture->get_class(), get_path(), p_texture->get_class())); } #endif