Fix #136235: Edit UV: Crash when modifying mesh in shaded viewport

This happened because the viewport was drawn after
the UV editor when some update occur (e.g. canceling an
operator). The requested UV edit batch would require only
one specific UV channel. The viewport, in need of a different
UV channel, requested a VBO rebuild (freing the old UV VBO)
but did not correctly clear the UV batches that were referencing
the said VBO. This lead to use after free which would sometime
works because the same memory would be reused for a random new
batch.

Pull Request: https://projects.blender.org/blender/blender/pulls/136780
This commit is contained in:
Clément Foucault
2025-03-31 18:45:59 +02:00
committed by Clément Foucault
parent 69a7c834b8
commit 9181485931

View File

@@ -1203,7 +1203,7 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph &task_graph,
drw_attributes_clear(&cache.attr_needed);
}
if (batch_requested & MBC_EDITUV) {
if ((batch_requested & MBC_EDITUV) || cd_uv_update) {
/* Discard UV batches if sync_selection changes */
const bool is_uvsyncsel = ts && (ts->uv_flag & UV_SYNC_SELECTION);
if (cd_uv_update || (cache.is_uvsyncsel != is_uvsyncsel)) {