Fix part of #131933: Crash with playback of deforming subdivision surface

The `ForeachContext` in `deform_coarse_vertices` does not use TLS but still has
a `func_free` callback set. Change the task API to allow this.

Pull Request: https://projects.blender.org/blender/blender/pulls/132498
This commit is contained in:
Brecht Van Lommel
2025-01-02 12:21:56 +01:00
committed by Brecht Van Lommel
parent 159038ce7c
commit 841ae6e8ab
2 changed files with 4 additions and 4 deletions

View File

@@ -84,7 +84,7 @@ void BLI_task_parallel_mempool(BLI_mempool *mempool,
}
if (use_userdata_chunk) {
if (settings->func_free != NULL) {
if (settings->func_free != NULL && userdata_chunk != NULL) {
/* `func_free` should only free data that was created during execution of `func`. */
settings->func_free(userdata, userdata_chunk);
}
@@ -138,7 +138,7 @@ void BLI_task_parallel_mempool(BLI_mempool *mempool,
settings->func_reduce(
userdata, userdata_chunk, mempool_iterator_data[i].tls.userdata_chunk);
}
if (settings->func_free) {
if (settings->func_free && mempool_iterator_data[i].tls.userdata_chunk != NULL) {
settings->func_free(userdata, mempool_iterator_data[i].tls.userdata_chunk);
}
}

View File

@@ -62,7 +62,7 @@ struct RangeTask {
~RangeTask()
{
if (settings->func_free != nullptr) {
if (settings->func_free != nullptr && userdata_chunk != nullptr) {
settings->func_free(userdata, userdata_chunk);
}
MEM_SAFE_FREE(userdata_chunk);
@@ -131,7 +131,7 @@ void BLI_task_parallel_range(const int start,
for (int i = start; i < stop; i++) {
func(userdata, i, &tls);
}
if (settings->func_free != nullptr) {
if (settings->func_free != nullptr && settings->userdata_chunk != nullptr) {
settings->func_free(userdata, settings->userdata_chunk);
}
}