Resolve memory leask with reports on initialization
authorCampbell Barton <ideasman42@gmail.com>
Wed, 18 Jun 2014 05:48:38 +0000 (15:48 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 18 Jun 2014 05:49:40 +0000 (15:49 +1000)
source/blender/editors/util/ed_util.c
source/blender/windowmanager/intern/wm_init_exit.c

index 2580836cad92bbc4f3ed67f939b582ab5e20eee0..178af8c836a26f246abd4170312b494a43ba405d 100644 (file)
@@ -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 */
index 675eb5e2e3a992bb22f42667bb70f7c34069cfc9..f1c0457fb388d6ddf807936c7e994f9d9046eba9 100644 (file)
 
 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 */