diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-04-13 20:03:52 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-04-13 20:03:52 +0400 |
commit | 440f4492656ec26c90017976553909b48e93c3fa (patch) | |
tree | fdfebcf240d9af24c095a14c717d56f7be130460 /source/blender/python/intern | |
parent | 152b253c2cfc5bc1b2669c4bf6accd4820d092a4 (diff) |
Fix #30858: UI losing buttons at some random moment after using Blender for a
while. This may not fix all cases but should at least solve the issue when
rendering with cycles.
The cause was a race condition on C->data.recursion, with multiple threads
accessing context at the same time. Cycles itself does not access context
from the render thread, but the bpy api would do a context update for any
callback in case e.g. a new file got loaded. Disabled that now in non-main
threads.
The ideal solution would be to not allow any context access at all from threads
but that's not so simple to implement, especially not this close to release.
Diffstat (limited to 'source/blender/python/intern')
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 7b362e56c73..f68ef6838e8 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -57,6 +57,7 @@ #include "BLI_string.h" #include "BLI_string_utf8.h" #include "BLI_utildefines.h" +#include "BLI_threads.h" #include "BKE_context.h" #include "BKE_text.h" @@ -95,6 +96,12 @@ static double bpy_timer_run_tot; /* accumulate python runs */ /* use for updating while a python script runs - in case of file load */ void bpy_context_update(bContext *C) { + /* don't do this from a non-main (e.g. render) thread, it can cause a race + condition on C->data.recursion. ideal solution would be to disable + context entirely from non-main threads, but that's more complicated */ + if(!BLI_thread_is_main()) + return; + BPy_SetContext(C); bpy_import_main_set(CTX_data_main(C)); BPY_modules_update(C); /* can give really bad results if this isn't here */ |