Python/Context: do not allow any UI context access from threads like render
or baking. This basically means you will only have access to bpy.data and bpy.context.scene, not current window, active object, etc, as those are not thread safe anyway and were likely to cause issues already. This fixes #30858, where the UI would lose buttons due to context getting corrupted when editing objects in pre/post render or using luxrender. The context access they did (indirectly) was only using the current scene or data so they still work.
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
@@ -245,6 +246,10 @@ static void *ctx_wm_python_context_get(const bContext *C, const char *member, vo
|
||||
(void)C, (void)member;
|
||||
#endif
|
||||
|
||||
/* don't allow UI context access from non-main threads */
|
||||
if (!BLI_thread_is_main())
|
||||
return NULL;
|
||||
|
||||
return fall_through;
|
||||
}
|
||||
|
||||
@@ -264,6 +269,11 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res
|
||||
// return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* don't allow UI context access from non-main threads */
|
||||
if (!BLI_thread_is_main())
|
||||
return done;
|
||||
|
||||
/* we check recursion to ensure that we do not get infinite
|
||||
* loops requesting data from ourselfs in a context callback */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user