diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-10-16 08:34:29 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2020-10-28 11:16:27 +0300 |
commit | 7e39e0a9f62b13e0b3a91df4cf9477a4eaef3dd9 (patch) | |
tree | bc25c67060932330d0de315ee99cd4baa854fd84 | |
parent | 89b5c9d433793ba7f34ee9b9f3008cd0a4608374 (diff) |
PyAPI: unregister add-ons when exiting
This lets add-on authors avoid false positive leaks when exiting.
In particular GPUShaders's although it applies to any PyObject that
stores memory allocated by guarded-alloc.
While this does add overhead on exit, on my system it's
under 1/100th of a second with all addons enabled.
See: T71362
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 66317770722..2cc14d6ab0f 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -528,6 +528,14 @@ void WM_exit_ex(bContext *C, const bool do_python) } } +#ifdef WITH_PYTHON + /* 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). */ + BPY_execute_string(C, (const char *[]){"addon_utils", NULL}, "addon_utils.disable_all()"); +#endif + BLI_timer_free(); WM_paneltype_clear(); |