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
This commit is contained in:
Campbell Barton 2020-10-16 16:34:29 +11:00 committed by Jeroen Bakker
parent 89b5c9d433
commit 7e39e0a9f6
Notes: blender-bot 2023-07-10 10:12:37 +02:00
Referenced by issue #77348, Blender LTS: Maintenance Task 2.83
1 changed files with 8 additions and 0 deletions

View File

@ -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();