Fix memory leak switching sculpt mode + dyntopo
authorCampbell Barton <ideasman42@gmail.com>
Thu, 7 Jul 2016 05:48:25 +0000 (15:48 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 7 Jul 2016 05:48:25 +0000 (15:48 +1000)
Auto-enabling dyntopo w/ mode switching leaked memory when undo was used.

source/blender/editors/sculpt_paint/sculpt.c

index 0931456058d97fad9528b7090c8296afc13bea4a..cc7531b978381d31345934f3207bc7f38b8b918f 100644 (file)
@@ -5462,7 +5462,10 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
                        }
 
                        if (message_unsupported == NULL) {
+                               /* undo push is needed to prevent memory leak */
+                               sculpt_undo_push_begin("Dynamic topology enable");
                                sculpt_dynamic_topology_enable(C);
+                               sculpt_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN);
                        }
                        else {
                                BKE_reportf(op->reports, RPT_WARNING,