PyAPI: Use separate writes for operator reports
authorCampbell Barton <ideasman42@gmail.com>
Sun, 12 Jul 2015 12:16:54 +0000 (22:16 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 12 Jul 2015 12:26:14 +0000 (22:26 +1000)
This allows us to temp override the stdout and extract individual reports

source/blender/python/intern/bpy_operator.c

index 8309938b632c0249cac08e757ed2cd027d56259b..fc17173a5d4d7fbef02b1dd993824a595b819c71 100644 (file)
@@ -36,6 +36,7 @@
 #include "RNA_types.h"
 
 #include "BLI_utildefines.h"
+#include "BLI_listbase.h"
 #include "BLI_string.h"
 
 #include "BPY_extern.h"
@@ -251,12 +252,10 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
                        error_val = BPy_reports_to_error(reports, PyExc_RuntimeError, false);
 
                        /* operator output is nice to have in the terminal/console too */
-                       if (reports->list.first) {
-                               char *report_str = BKE_reports_string(reports, 0); /* all reports */
-       
-                               if (report_str) {
-                                       PySys_WriteStdout("%s\n", report_str);
-                                       MEM_freeN(report_str);
+                       if (!BLI_listbase_is_empty(&reports->list)) {
+                               Report *report;
+                               for (report = reports->list.first; report; report = report->next) {
+                                       PySys_WriteStdout("%s: %s\n", report->typestr, report->message);
                                }
                        }