Fix T38664: Blender hang when change scene from script

Deadlock between python script evaluation thread and
drivers evaluation caused by scene update invoked from
ED_screen_set_scene().

Pretty much the same as setting scene current frame
with the same solution BPy_{BEGIN,END}_ALLOW_THREADS.
This commit is contained in:
Sergey Sharybin 2014-02-17 12:33:00 +06:00
parent 4134bdc75c
commit 1562fd99f1

@ -60,6 +60,10 @@ EnumPropertyItem region_type_items[] = {
#include "UI_view2d.h" #include "UI_view2d.h"
#ifdef WITH_PYTHON
# include "BPY_extern.h"
#endif
static void rna_Screen_scene_set(PointerRNA *ptr, PointerRNA value) static void rna_Screen_scene_set(PointerRNA *ptr, PointerRNA value)
{ {
bScreen *sc = (bScreen *)ptr->data; bScreen *sc = (bScreen *)ptr->data;
@ -76,7 +80,16 @@ static void rna_Screen_scene_update(bContext *C, PointerRNA *ptr)
/* exception: must use context so notifier gets to the right window */ /* exception: must use context so notifier gets to the right window */
if (sc->newscene) { if (sc->newscene) {
#ifdef WITH_PYTHON
BPy_BEGIN_ALLOW_THREADS;
#endif
ED_screen_set_scene(C, sc, sc->newscene); ED_screen_set_scene(C, sc, sc->newscene);
#ifdef WITH_PYTHON
BPy_END_ALLOW_THREADS;
#endif
WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, sc->newscene); WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, sc->newscene);
if (G.debug & G_DEBUG) if (G.debug & G_DEBUG)