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:
Diffstat (limited to 'source/blender/windowmanager/intern/wm_init_exit.c')
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index b85bf8cb323..926e61f4a0e 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -72,20 +72,22 @@
#include "BKE_addon.h"
#include "BKE_appdir.h"
-#include "BKE_mask.h" /* free mask clipboard */
-#include "BKE_material.h" /* BKE_material_copybuf_clear */
-#include "BKE_sequencer.h" /* free seq clipboard */
+#include "BKE_mask.h" /* free mask clipboard */
+#include "BKE_material.h" /* BKE_material_copybuf_clear */
#include "BKE_studiolight.h"
#include "BKE_tracking.h" /* free tracking clipboard */
#include "RE_engine.h"
#include "RE_pipeline.h" /* RE_ free stuff */
+#include "SEQ_sequencer.h" /* free seq clipboard */
+
#include "IMB_thumbs.h"
#ifdef WITH_PYTHON
# include "BPY_extern.h"
# include "BPY_extern_python.h"
+# include "BPY_extern_run.h"
#endif
#include "GHOST_C-api.h"
@@ -190,8 +192,6 @@ void WM_init_opengl(void)
GPU_pass_cache_init();
- BKE_subdiv_init();
-
opengl_is_init = true;
}
@@ -204,7 +204,7 @@ static void sound_jack_sync_callback(Main *bmain, int mode, double time)
wmWindowManager *wm = bmain->wm.first;
- for (wmWindow *window = wm->windows.first; window != NULL; window = window->next) {
+ LISTBASE_FOREACH (wmWindow *, window, &wm->windows) {
Scene *scene = WM_window_get_active_scene(window);
if ((scene->audio.flag & AUDIO_SYNC) == 0) {
continue;
@@ -323,6 +323,8 @@ void WM_init(bContext *C, int argc, const char **argv)
UI_init();
}
+ BKE_subdiv_init();
+
ED_spacemacros_init();
/* note: there is a bug where python needs initializing before loading the
@@ -334,9 +336,7 @@ void WM_init(bContext *C, int argc, const char **argv)
* Will try fix when the crash can be repeated. - campbell. */
#ifdef WITH_PYTHON
- BPY_context_set(C); /* necessary evil */
- BPY_python_start(argc, argv);
-
+ BPY_python_start(C, argc, argv);
BPY_python_reset(C);
#else
(void)argc; /* unused */
@@ -480,8 +480,6 @@ void WM_exit_ex(bContext *C, const bool do_python)
/* modal handlers are on window level freed, others too? */
/* note; same code copied in wm_files.c */
if (C && wm) {
- wmWindow *win;
-
if (!G.background) {
struct MemFile *undo_memfile = wm->undo_stack ?
ED_undosys_stack_memfile_get_active(wm->undo_stack) :
@@ -508,8 +506,7 @@ void WM_exit_ex(bContext *C, const bool do_python)
WM_jobs_kill_all(wm);
- for (win = wm->windows.first; win; win = win->next) {
-
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
CTX_wm_window_set(C, win); /* needed by operator close callbacks */
WM_event_remove_handlers(C, &win->handlers);
WM_event_remove_handlers(C, &win->modalhandlers);
@@ -525,6 +522,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();