WM: free operators when repeating
authorCampbell Barton <ideasman42@gmail.com>
Tue, 14 Mar 2017 18:16:07 +0000 (05:16 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 14 Mar 2017 18:37:42 +0000 (05:37 +1100)
Needed since the active operator isn't ensured to be the last.

source/blender/editors/screen/screen_ops.c
source/blender/editors/util/undo.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm.c

index 1c17f8c12ff7111d1f26f5c6704121aaf4b38ab0..d88c36a8e242d6850de44de9c18d5817877f13bd 100644 (file)
@@ -2903,7 +2903,8 @@ static void SCREEN_OT_spacedata_cleanup(wmOperatorType *ot)
 
 static int repeat_last_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       wmOperator *lastop = CTX_wm_manager(C)->operators.last;
+       wmWindowManager *wm = CTX_wm_manager(C);
+       wmOperator *lastop = wm->operators.last;
 
        /* Seek last registered operator */
        while (lastop) {
@@ -2916,6 +2917,7 @@ static int repeat_last_exec(bContext *C, wmOperator *UNUSED(op))
        }
 
        if (lastop) {
+               WM_operator_free_all_after(wm, lastop);
                WM_operator_repeat(C, lastop);
        }
        
index fab5b7e821f31658411c5311392b7a744f9b51c3..4e021d4833ebc56641242ff973810b02e2f696e9 100644 (file)
@@ -419,6 +419,9 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
 
                        if (G.debug & G_DEBUG)
                                printf("redo_cb: operator redo %s\n", op->type->name);
+
+                       WM_operator_free_all_after(wm, op);
+
                        ED_undo_pop_op(C, op);
 
                        if (op->type->check) {
index a33f4277a4e7c2ea47e76228d3f4e23ffa084a2a..1cfd20defe0fb158dec687ced7e560c30ed78030 100644 (file)
@@ -252,6 +252,7 @@ int         WM_operator_confirm_message(struct bContext *C, struct wmOperator *o
 
                /* operator api */
 void           WM_operator_free                (struct wmOperator *op);
+void           WM_operator_free_all_after(wmWindowManager *wm, struct wmOperator *op);
 void           WM_operator_type_set(struct wmOperator *op, struct wmOperatorType *ot);
 void           WM_operator_stack_clear(struct wmWindowManager *wm);
 void           WM_operator_handlers_clear(wmWindowManager *wm, struct wmOperatorType *ot);
index 8fe38a97dac360a7d0605a6ba8fe28c33edbe11a..4351cd22b18e75e962c19bc76663eb8524a32e45 100644 (file)
@@ -107,6 +107,17 @@ void WM_operator_free(wmOperator *op)
        MEM_freeN(op);
 }
 
+void WM_operator_free_all_after(wmWindowManager *wm, struct wmOperator *op)
+{
+       op = op->next;
+       while (op != NULL) {
+               wmOperator *op_next = op->next;
+               BLI_remlink(&wm->operators, op);
+               WM_operator_free(op);
+               op = op_next;
+       }
+}
+
 /**
  * Use with extreme care!,
  * properties, customdata etc - must be compatible.