From a3ce413f44ba13b5e95e53d3dc11a92a16ac1dd5 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Mon, 14 Sep 2009 16:00:42 +0000 Subject: Bugfix with py operator api and modal operators. Modal operators would keep a reference to Reports locally allocated in the api functions, which would crash and burn later when the operator would actually stop. This commit introduces a flag at the Reports level that can be used to indicate that it needs to be freed (on top of the flag already existing in the operator, which I guess could be removed). Reports for operators called through python are only persisted if they indicate that they are running modal. --- source/blender/python/intern/bpy_operator.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'source/blender/python/intern/bpy_operator.c') diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index 062db42e0e9..0c1d974c978 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -79,16 +79,21 @@ static PyObject *pyop_call( PyObject * self, PyObject * args) if (error_val==0) { - ReportList reports; + ReportList *reports; - BKE_reports_init(&reports, RPT_STORE); + reports= MEM_mallocN(sizeof(ReportList), "wmOperatorReportList"); + BKE_reports_init(reports, RPT_STORE); - WM_operator_call_py(C, ot, context, &ptr, &reports); + WM_operator_call_py(C, ot, context, &ptr, reports); - if(BPy_reports_to_error(&reports)) + if(BPy_reports_to_error(reports)) error_val = -1; - BKE_reports_clear(&reports); + BKE_reports_clear(reports); + if ((reports->flag & RPT_FREE) == 0) + { + MEM_freeN(reports); + } } WM_operator_properties_free(&ptr); -- cgit v1.2.3