From 919006eb3511f4e2b8fa1e37ddb35f84863789f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Fri, 15 Aug 2025 20:22:42 +0200 Subject: [PATCH] Fix material removal clearing all instances of shared texture arrays --- drivers/gles3/storage/material_storage.cpp | 3 ++- servers/rendering/renderer_rd/storage_rd/material_storage.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gles3/storage/material_storage.cpp b/drivers/gles3/storage/material_storage.cpp index 0860f72a42b..b87509cdb96 100644 --- a/drivers/gles3/storage/material_storage.cpp +++ b/drivers/gles3/storage/material_storage.cpp @@ -2398,7 +2398,8 @@ void MaterialStorage::material_free(RID p_rid) { // This happens when the app is being closed. for (KeyValue &E : material->params) { if (E.value.get_type() == Variant::ARRAY) { - Array(E.value).clear(); + // Clear the array for this material only (the array may be shared). + E.value = Variant(); } } diff --git a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp index 80183825390..61cbbc361b2 100644 --- a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp @@ -2235,7 +2235,8 @@ void MaterialStorage::material_free(RID p_rid) { // This happens when the app is being closed. for (KeyValue &E : material->params) { if (E.value.get_type() == Variant::ARRAY) { - Array(E.value).clear(); + // Clear the array for this material only (the array may be shared). + E.value = Variant(); } }