diff options
author | Martin Poirier <theeth@yahoo.com> | 2009-09-14 20:00:42 +0400 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2009-09-14 20:00:42 +0400 |
commit | a3ce413f44ba13b5e95e53d3dc11a92a16ac1dd5 (patch) | |
tree | 3c26fd7286fe7ceff7c0b72361a92a2d3f41020b /source/blender/python/intern | |
parent | 733b20f695ab43fb979963b82683aceedf25b8c8 (diff) |
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.
Diffstat (limited to 'source/blender/python/intern')
-rw-r--r-- | source/blender/python/intern/bpy_operator.c | 15 |
1 files changed, 10 insertions, 5 deletions
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); |