Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2017-07-19 13:55:05 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2017-07-19 13:55:05 +0300
commit73adf3e27d43c8c739ae86a0634392ae316a29fe (patch)
tree7a2b75de3cd6fe7d3426002732e8dd62443194fb /source/blender/editors/space_file/filelist.c
parent5376b3eeca6ee54470808dd7bb10d3d0d44be36b (diff)
Fix (unreported) seldom crash when using previews in filebrowser.
Hopefully fix it actually, at least could not reproduce it anymore with that changen, but Was already quite hard to trigger before. We need a memory barrier at this allocation, otherwise it might happen after preview gets added to done queue, so preview could end up being freed twice, leading to crash.
Diffstat (limited to 'source/blender/editors/space_file/filelist.c')
-rw-r--r--source/blender/editors/space_file/filelist.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 8e548d7a9bd..d94aad640b7 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -1116,7 +1116,10 @@ static void filelist_cache_preview_runf(TaskPool *__restrict pool, void *taskdat
preview->img = IMB_thumb_manage(preview->path, THB_LARGE, source);
IMB_thumb_path_unlock(preview->path);
- preview->flags = 0; /* Used to tell free func to not free anything! */
+ /* Used to tell free func to not free anything.
+ * Note that we do not care about cas result here,
+ * we only want value attribution itself to be atomic (and memory barier).*/
+ atomic_cas_uint32(&preview->flags, preview->flags, 0);
BLI_thread_queue_push(cache->previews_done, preview);
// printf("%s: End (%d)...\n", __func__, threadid);