diff options
author | Campbell Barton <campbell@blender.org> | 2022-09-14 07:06:44 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-09-14 07:06:44 +0300 |
commit | d26220d97ab13f39b791468728a6089500d22caa (patch) | |
tree | 9980107e8db0e8b91b44fdbc8678a3ee2d863cd1 /source/blender/blenkernel | |
parent | 7bd60d40efbfaa3a18d3cfee409a1a3d1fa6c11d (diff) |
Fix reports printing twice when called from Python in background-mode
Calling operators in background-mode always printed with the
assumption that output should never be hidden.
However operators called from `bpy.ops` were also printing reports to
the `stdout` (needed for the Python console and generally useful).
Resolve by adding a flag to signal that the owner of the ReportList
is responsible for printing to the `stdout`.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/report.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index 6d654730bca..ccec9c346a8 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -258,10 +258,20 @@ char *BKE_reports_string(ReportList *reports, eReportType level) bool BKE_reports_print_test(const ReportList *reports, eReportType type) { + if (reports == NULL) { + return true; + } + if (reports->flag & RPT_PRINT_HANDLED_BY_OWNER) { + return false; + } /* In background mode always print otherwise there are cases the errors won't be displayed, - * but still add to the report list since this is used for python exception handling. */ - return (G.background || (reports == NULL) || - ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))); + * but still add to the report list since this is used for Python exception handling. */ + if (G.background) { + return true; + } + + /* Common case. */ + return (reports->flag & RPT_PRINT) && (type >= reports->printlevel); } void BKE_reports_print(ReportList *reports, eReportType level) |