/* context should be used but not now because it causes some bugs */ void bpy_context_clear(bContext *UNUSED(C), PyGILState_STATE *gilstate) { py_call_level--; if (gilstate) PyGILState_Release(*gilstate); if (py_call_level < 0) { fprintf(stderr, "ERROR: Python context internal state bug. this should not happen!\n"); } else if (py_call_level == 0) { /* XXX - Calling classes currently wont store the context :\, * cant set NULL because of this. but this is very flakey still. */ #if 0 BPy_SetContext(NULL); bpy_import_main_set(NULL); #endif #ifdef TIME_PY_RUN bpy_timer_run_tot += PIL_check_seconds_timer() - bpy_timer_run; bpy_timer_count++; #endif } }
/* 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 */ }
void BPY_context_set(bContext *C) { BPy_SetContext(C); }
/* use for updating while a python script runs - in case of file load */ void bpy_context_update(bContext *C) { BPy_SetContext(C); bpy_import_main_set(CTX_data_main(C)); BPY_modules_update(C); /* can give really bad results if this isnt here */ }