Merge pull request #100632 from Namey5/decal-duplication-crash

Fix crash when duplicating `Decal` or `Light3D` nodes
This commit is contained in:
Rémi Verschelde 2024-12-20 23:57:05 +01:00
commit 024b6bc1ce
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 16 additions and 16 deletions

View file

@ -46,14 +46,14 @@ void Decal::set_texture(DecalTexture p_type, const Ref<Texture2D> &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

View file

@ -202,14 +202,14 @@ void Light3D::set_projector(const Ref<Texture2D> &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