bugfix [#22845] Python operators dont free report list
authorCampbell Barton <ideasman42@gmail.com>
Fri, 13 Aug 2010 16:34:21 +0000 (16:34 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 13 Aug 2010 16:34:21 +0000 (16:34 +0000)
source/blender/windowmanager/intern/wm_event_system.c

index 867700980af58f93d20184a52a1da3156ab138ff..e1fc934ee3eb061ff0b42662507f40b0c114a00c 100644 (file)
@@ -425,6 +425,14 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int pop
        }
 }
 
+/* this function is mainly to check that the rules for freeing
+ * an operator are kept in sync.
+ */
+static int wm_operator_register_check(wmWindowManager *wm, wmOperatorType *ot)
+{
+       return (wm->op_undo_depth == 0) && (ot->flag & OPTYPE_REGISTER);
+}
+
 static void wm_operator_finished(bContext *C, wmOperator *op, int repeat)
 {
        wmWindowManager *wm= CTX_wm_manager(C);
@@ -445,7 +453,7 @@ static void wm_operator_finished(bContext *C, wmOperator *op, int repeat)
                        MEM_freeN(buf);
                }
 
-               if((wm->op_undo_depth == 0) && (op->type->flag & OPTYPE_REGISTER))
+               if(wm_operator_register_check(wm, op->type))
                        wm_operator_register(C, op);
                else
                        WM_operator_free(op);
@@ -807,11 +815,11 @@ int WM_operator_name_call(bContext *C, const char *opstring, int context, Pointe
 */
 int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA *properties, ReportList *reports)
 {
+       wmWindowManager *wm=    CTX_wm_manager(C);
        int retval= OPERATOR_CANCELLED;
 
 #if 0
        wmOperator *op;
-       wmWindowManager *wm=    CTX_wm_manager(C);
        op= wm_operator_create(wm, ot, properties, reports);
 
        if (op->type->exec) {
@@ -830,9 +838,9 @@ int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA
        retval= wm_operator_call_internal(C, ot, context, properties, reports);
        
        /* keep the reports around if needed later */
-       if (retval & OPERATOR_RUNNING_MODAL || ot->flag & OPTYPE_REGISTER)
+       if (retval & OPERATOR_RUNNING_MODAL || wm_operator_register_check(wm, ot))
        {
-               reports->flag |= RPT_FREE;
+               reports->flag |= RPT_FREE; /* let blender manage freeing */
        }
        
        return retval;