diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-01-28 06:38:08 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-01-28 06:38:08 +0300 |
commit | 87d3f4aff3225104cbb8be41ac0339c6a1cd9a85 (patch) | |
tree | 2e4e4f83b7653465ec39a9135c8f932337298a85 /source/blender/windowmanager/intern/wm_init_exit.c | |
parent | 198980693ba7b183f7d2a32a21b65338edfdeb10 (diff) |
Fix T82675: Crash on exit when Blender is built as a Python module
Diffstat (limited to 'source/blender/windowmanager/intern/wm_init_exit.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 608aa116239..918836041df 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -523,11 +523,15 @@ void WM_exit_ex(bContext *C, const bool do_python) } } -#ifdef WITH_PYTHON +#if defined(WITH_PYTHON) && !defined(WITH_PYTHON_MODULE) /* Without this, we there isn't a good way to manage false-positive resource leaks * where a #PyObject references memory allocated with guarded-alloc, T71362. * - * This allows add-ons to free resources when unregistered (which is good practice anyway). */ + * This allows add-ons to free resources when unregistered (which is good practice anyway). + * + * Don't run this code when built as a Python module as this runs when Python is in the + * process of shutting down, where running a snippet like this will crash, see T82675. + * Instead use the `atexit` module, installed by #BPY_python_start */ BPY_run_string_eval(C, (const char *[]){"addon_utils", NULL}, "addon_utils.disable_all()"); #endif |