From b16bf6c3d4204ba5399f9854f7888630e984fe59 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 18 Jun 2014 15:48:38 +1000 Subject: [PATCH] Resolve memory leask with reports on initialization --- source/blender/editors/util/ed_util.c | 12 +++++++++++- source/blender/windowmanager/intern/wm_init_exit.c | 10 ++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 2580836cad9..178af8c836a 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -41,7 +41,9 @@ #include "DNA_scene_types.h" #include "DNA_packedFile_types.h" -#include "BLI_blenlib.h" +#include "BLI_utildefines.h" +#include "BLI_string.h" +#include "BLI_path_util.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -82,6 +84,12 @@ void ED_editors_init(bContext *C) Object *ob, *obact = (sce && sce->basact) ? sce->basact->object : NULL; ID *data; + /* This is called during initialization, so we don't want to store any reports */ + ReportList *reports = CTX_wm_reports(C); + int reports_flag_prev = reports->flag &= ~RPT_STORE; + + SWAP(int, reports->flag, reports_flag_prev); + /* toggle on modes for objects that were saved with these enabled. for * e.g. linked objects we have to ensure that they are actually the * active object in this scene. */ @@ -101,6 +109,8 @@ void ED_editors_init(bContext *C) if (sce) { ED_space_image_paint_update(wm, sce->toolsettings); } + + SWAP(int, reports->flag, reports_flag_prev); } /* frees all editmode stuff */ diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 675eb5e2e3a..f1c0457fb38 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -117,11 +117,17 @@ static void wm_init_reports(bContext *C) { - BKE_reports_init(CTX_wm_reports(C), RPT_STORE); + ReportList *reports = CTX_wm_reports(C); + + BLI_assert(!reports || BLI_listbase_is_empty(&reports->list)); + + BKE_reports_init(reports, RPT_STORE); } static void wm_free_reports(bContext *C) { - BKE_reports_clear(CTX_wm_reports(C)); + ReportList *reports = CTX_wm_reports(C); + + BKE_reports_clear(reports); } bool wm_start_with_console = false; /* used in creator.c */