Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-04-06 09:15:11 +0300
committerCampbell Barton <campbell@blender.org>2022-04-06 11:02:58 +0300
commit2d2baeaf04d481f284bc2f098fb6d7ee9268151f (patch)
treedee60d7075b6febe402323d5b12085bdff544630 /source/blender/blenkernel/intern
parente4f71e5ef345070dc0b21df35a049184d3e46645 (diff)
Fix: T78228 Send all python errors to info editor
Python exceptions are now shown in the info editor, this also resolves an old bug where errors were printed twice. This was originally based on D9752 by @ShadowChaser although many changes have been made from the original patch. Details: - BPy_errors_to_report no longer prints additional output. - BKE_report_print_test was added so it's possible to check if calling BKE_report also printed to the stdout. - Callers to BPy_errors_to_report are responsible for ensuring output is printed to the stdout/stderr. - Python exceptions no longer add a trailing newline, needed to avoid blank-space when displayed in the info-editor.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/report.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c
index 98b680c8054..6d654730bca 100644
--- a/source/blender/blenkernel/intern/report.c
+++ b/source/blender/blenkernel/intern/report.c
@@ -86,9 +86,7 @@ void BKE_report(ReportList *reports, eReportType type, const char *_message)
int len;
const char *message = TIP_(_message);
- /* 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 */
- if (G.background || !reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) {
+ if (BKE_reports_print_test(reports, type)) {
printf("%s: %s\n", BKE_report_type_str(type), message);
fflush(stdout); /* this ensures the message is printed before a crash */
}
@@ -115,7 +113,7 @@ void BKE_reportf(ReportList *reports, eReportType type, const char *_format, ...
va_list args;
const char *format = TIP_(_format);
- if (G.background || !reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) {
+ if (BKE_reports_print_test(reports, type)) {
printf("%s: ", BKE_report_type_str(type));
va_start(args, _format);
vprintf(format, args);
@@ -258,6 +256,14 @@ char *BKE_reports_string(ReportList *reports, eReportType level)
return cstring;
}
+bool BKE_reports_print_test(const ReportList *reports, eReportType type)
+{
+ /* 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)));
+}
+
void BKE_reports_print(ReportList *reports, eReportType level)
{
char *cstring = BKE_reports_string(reports, level);