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.
This commit is contained in:
2009-09-14 16:00:42 +00:00
parent 733b20f695
commit a3ce413f44
4 changed files with 17 additions and 6 deletions

View File

@@ -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);