Browse Source

Fix material removal clearing all instances of shared texture arrays

Pedro J. Estébanez 4 weeks ago
parent
commit
919006eb35

+ 2 - 1
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<StringName, Variant> &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();
 		}
 	}
 

+ 2 - 1
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<StringName, Variant> &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();
 		}
 	}