forked from bartvdbraak/blender
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.
This commit is contained in:
parent
152b253c2c
commit
440f449265
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user