Changeset View
Changeset View
Standalone View
Standalone View
source/blender/python/intern/bpy_interface.c
| Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | |||||
| #ifdef TIME_PY_RUN | #ifdef TIME_PY_RUN | ||||
| # include "PIL_time.h" | # include "PIL_time.h" | ||||
| static int bpy_timer_count = 0; | static int bpy_timer_count = 0; | ||||
| static double bpy_timer; /* time since python starts */ | static double bpy_timer; /* time since python starts */ | ||||
| static double bpy_timer_run; /* time for each python script run */ | static double bpy_timer_run; /* time for each python script run */ | ||||
| static double bpy_timer_run_tot; /* accumulate python runs */ | static double bpy_timer_run_tot; /* accumulate python runs */ | ||||
| #endif | #endif | ||||
| bool py_use_system_env = false; | |||||
LazyDodo: nitpicking: static ? | |||||
| /* use for updating while a python script runs - in case of file load */ | /* use for updating while a python script runs - in case of file load */ | ||||
| void BPY_context_update(bContext *C) | void BPY_context_update(bContext *C) | ||||
| { | { | ||||
| /* don't do this from a non-main (e.g. render) thread, it can cause a race | /* 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 | * condition on C->data.recursion. ideal solution would be to disable | ||||
| * context entirely from non-main threads, but that's more complicated */ | * context entirely from non-main threads, but that's more complicated */ | ||||
| if (!BLI_thread_is_main()) { | if (!BLI_thread_is_main()) { | ||||
| return; | return; | ||||
| ▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | #ifndef WITH_PYTHON_MODULE | ||||
| * so use a more relaxed error handler and enforce utf-8 since the rest of | * so use a more relaxed error handler and enforce utf-8 since the rest of | ||||
| * blender is utf-8 too - campbell */ | * blender is utf-8 too - campbell */ | ||||
| Py_SetStandardStreamEncoding("utf-8", "surrogateescape"); | Py_SetStandardStreamEncoding("utf-8", "surrogateescape"); | ||||
| /* Suppress error messages when calculating the module search path. | /* Suppress error messages when calculating the module search path. | ||||
| * While harmless, it's noisy. */ | * While harmless, it's noisy. */ | ||||
| Py_FrozenFlag = 1; | Py_FrozenFlag = 1; | ||||
| /* Only use the systems environment variables when explicitly requested. */ | |||||
| Py_IgnoreEnvironmentFlag = !py_use_system_env; | |||||
| Py_Initialize(); | Py_Initialize(); | ||||
| // PySys_SetArgv(argc, argv); /* broken in py3, not a huge deal */ | // PySys_SetArgv(argc, argv); /* broken in py3, not a huge deal */ | ||||
| /* sigh, why do python guys not have a (char **) version anymore? */ | /* sigh, why do python guys not have a (char **) version anymore? */ | ||||
| { | { | ||||
| int i; | int i; | ||||
| PyObject *py_argv = PyList_New(argc); | PyObject *py_argv = PyList_New(argc); | ||||
| for (i = 0; i < argc; i++) { | for (i = 0; i < argc; i++) { | ||||
| ▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | void BPY_python_reset(bContext *C) | ||||
| G.f &= ~(G_FLAG_SCRIPT_AUTOEXEC_FAIL | G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET); | G.f &= ~(G_FLAG_SCRIPT_AUTOEXEC_FAIL | G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET); | ||||
| G.autoexec_fail[0] = '\0'; | G.autoexec_fail[0] = '\0'; | ||||
| BPY_driver_reset(); | BPY_driver_reset(); | ||||
| BPY_app_handlers_reset(false); | BPY_app_handlers_reset(false); | ||||
| BPY_modules_load_user(C); | BPY_modules_load_user(C); | ||||
| } | } | ||||
| void BPY_python_use_system_env(void) | |||||
| { | |||||
| py_use_system_env = true; | |||||
| } | |||||
| static void python_script_error_jump_text(struct Text *text) | static void python_script_error_jump_text(struct Text *text) | ||||
| { | { | ||||
| int lineno; | int lineno; | ||||
| int offset; | int offset; | ||||
| python_script_error_jump(text->id.name + 2, &lineno, &offset); | python_script_error_jump(text->id.name + 2, &lineno, &offset); | ||||
| if (lineno != -1) { | if (lineno != -1) { | ||||
| /* select the line with the error */ | /* select the line with the error */ | ||||
| txt_move_to(text, lineno - 1, INT_MAX, false); | txt_move_to(text, lineno - 1, INT_MAX, false); | ||||
| ▲ Show 20 Lines • Show All 620 Lines • Show Last 20 Lines | |||||
nitpicking: static ?