diff options
author | Julian Eisel <julian@blender.org> | 2021-12-06 19:46:21 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-12-07 13:47:06 +0300 |
commit | 4312cb854517ded8a576c2b53c8e92258eed7cce (patch) | |
tree | 7ca0d50e37685dec1eaa9d056cda10f12340adfb | |
parent | cd494087c1f214771d952d110ed2a1a685e7ec28 (diff) |
Fix memory leak when loading large asset libraries
-rw-r--r-- | source/blender/editors/space_file/filelist.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 6593894d9a6..a580cf672f4 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -1624,6 +1624,9 @@ static void filelist_cache_preview_runf(TaskPool *__restrict pool, void *taskdat preview->icon_id = BKE_icon_imbuf_create(imbuf); } + /* Move ownership to the done queue. */ + preview_taskdata->preview = NULL; + BLI_thread_queue_push(cache->previews_done, preview); atomic_fetch_and_sub_z(&cache->previews_todo_count, 1); @@ -1633,6 +1636,12 @@ static void filelist_cache_preview_runf(TaskPool *__restrict pool, void *taskdat static void filelist_cache_preview_freef(TaskPool *__restrict UNUSED(pool), void *taskdata) { FileListEntryPreviewTaskData *preview_taskdata = taskdata; + + /* In case the preview wasn't moved to the "done" queue yet. */ + if (preview_taskdata->preview) { + MEM_freeN(preview_taskdata->preview); + } + MEM_freeN(preview_taskdata); } |