Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-10-16 08:34:29 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-10-16 08:34:29 +0300
commitfa566157a5c351775d082b05b180c630665b4afc (patch)
tree804614780a675eefff3c4ebfcb6db60446fb33be /source/blender/windowmanager/intern/wm_init_exit.c
parentf40294b2d68ba126bbdd3d39ce54148dd6f5bf9a (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
Diffstat (limited to 'source/blender/windowmanager/intern/wm_init_exit.c')
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 4ec3e1297d2..de47234695e 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -86,6 +86,7 @@
#ifdef WITH_PYTHON
# include "BPY_extern.h"
# include "BPY_extern_python.h"
+# include "BPY_extern_run.h"
#endif
#include "GHOST_C-api.h"
@@ -523,6 +524,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_run_string_eval(C, (const char *[]){"addon_utils", NULL}, "addon_utils.disable_all()");
+#endif
+
BLI_timer_free();
WM_paneltype_clear();