[Bf-blender-cvs] [7e39e0a9f62] blender-v2.83-release: PyAPI: unregister add-ons when exiting

Campbell Barton noreply at git.blender.org
Wed Oct 28 09:55:51 CET 2020


Commit: 7e39e0a9f62b13e0b3a91df4cf9477a4eaef3dd9
Author: Campbell Barton
Date:   Fri Oct 16 16:34:29 2020 +1100
Branches: blender-v2.83-release
https://developer.blender.org/rB7e39e0a9f62b13e0b3a91df4cf9477a4eaef3dd9

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

===================================================================

M	source/blender/windowmanager/intern/wm_init_exit.c

===================================================================

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



More information about the Bf-blender-cvs mailing list