Fix T61035 Draw manager crash opening file with curves

Move free callback call to GPU_batch_discard to prevent the crash.

The issue was that clearing can happen after referencing to an instance
buffer and that's perfectly legal.
This commit is contained in:
Clément Foucault 2019-04-05 17:48:14 +02:00
parent d140e597a6
commit e559074c4e
Notes: blender-bot 2023-02-14 05:59:31 +01:00
Referenced by issue #61035, Draw manager crash opening file with curves
2 changed files with 5 additions and 5 deletions

View File

@ -106,7 +106,7 @@ void GPU_batch_copy(GPUBatch *batch_dst, GPUBatch *batch_src);
#define GPU_batch_init(batch, prim, verts, elem) \
GPU_batch_init_ex(batch, prim, verts, elem, 0)
void GPU_batch_clear(GPUBatch *); /* Same as discard but does not free. */
void GPU_batch_clear(GPUBatch *); /* Same as discard but does not free. (does not clal free callback) */
void GPU_batch_discard(GPUBatch *); /* verts & elem are not discarded */
void GPU_batch_vao_cache_clear(GPUBatch *);

View File

@ -120,10 +120,6 @@ void GPU_batch_copy(GPUBatch *batch_dst, GPUBatch *batch_src)
void GPU_batch_clear(GPUBatch *batch)
{
if (batch->free_callback) {
batch->free_callback(batch, batch->callback_data);
}
if (batch->owns_flag & GPU_BATCH_OWNS_INDEX) {
GPU_indexbuf_discard(batch->elem);
}
@ -145,6 +141,10 @@ void GPU_batch_clear(GPUBatch *batch)
void GPU_batch_discard(GPUBatch *batch)
{
if (batch->free_callback) {
batch->free_callback(batch, batch->callback_data);
}
GPU_batch_clear(batch);
MEM_freeN(batch);
}