mirror of
https://github.com/godotengine/godot.git
synced 2025-11-03 15:11:19 +00:00
Clear material arrays to prevent freeing of invalid texture RID
This commit is contained in:
parent
228db366bf
commit
01cddbb12a
2 changed files with 16 additions and 0 deletions
|
|
@ -2765,6 +2765,14 @@ void MaterialStorage::material_free(RID p_rid) {
|
||||||
Material *material = material_owner.get_or_null(p_rid);
|
Material *material = material_owner.get_or_null(p_rid);
|
||||||
ERR_FAIL_COND(!material);
|
ERR_FAIL_COND(!material);
|
||||||
|
|
||||||
|
// Need to clear texture arrays to prevent spin locking of their RID's.
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
material_set_shader(p_rid, RID()); //clean up shader
|
material_set_shader(p_rid, RID()); //clean up shader
|
||||||
material->dependency.deleted_notify(p_rid);
|
material->dependency.deleted_notify(p_rid);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2685,6 +2685,14 @@ void MaterialStorage::material_free(RID p_rid) {
|
||||||
Material *material = material_owner.get_or_null(p_rid);
|
Material *material = material_owner.get_or_null(p_rid);
|
||||||
ERR_FAIL_COND(!material);
|
ERR_FAIL_COND(!material);
|
||||||
|
|
||||||
|
// Need to clear texture arrays to prevent spin locking of their RID's.
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
material_set_shader(p_rid, RID()); //clean up shader
|
material_set_shader(p_rid, RID()); //clean up shader
|
||||||
material->dependency.deleted_notify(p_rid);
|
material->dependency.deleted_notify(p_rid);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue