[Bf-blender-cvs] [abdfa4c6505] soc-2020-info-editor: Fix: do not check error by printed string

Mateusz Grzeliński noreply at git.blender.org
Wed Jul 8 15:14:48 CEST 2020


Commit: abdfa4c6505903abdd5061dd26b6818b39dba2b4
Author: Mateusz Grzeliński
Date:   Wed Jul 8 12:41:46 2020 +0200
Branches: soc-2020-info-editor
https://developer.blender.org/rBabdfa4c6505903abdd5061dd26b6818b39dba2b4

Fix: do not check error by printed string

===================================================================

M	source/blender/python/intern/bpy_capi_utils.c

===================================================================

diff --git a/source/blender/python/intern/bpy_capi_utils.c b/source/blender/python/intern/bpy_capi_utils.c
index 338a9840699..efc007224cc 100644
--- a/source/blender/python/intern/bpy_capi_utils.c
+++ b/source/blender/python/intern/bpy_capi_utils.c
@@ -67,18 +67,19 @@ char *BPy_enum_as_string(const EnumPropertyItem *item)
 
 short BPy_reports_to_error(ReportList *reports, PyObject *exception, const bool clear)
 {
-  char *report_str = BKE_reports_sprintfN(reports, RPT_ERROR);
+  const bool are_reports_empty = BLI_listbase_is_empty(&reports->list);
 
-  if (clear == true) {
-    BKE_reports_clear(reports);
-  }
-
-  if (report_str) {
+  if (!are_reports_empty) {
+    char *report_str = BKE_reports_sprintfN(reports, RPT_ERROR);
     PyErr_SetString(exception, report_str);
     MEM_freeN(report_str);
   }
 
-  return (report_str == NULL) ? 0 : -1;
+  if (clear) {
+    BKE_reports_clear(reports);
+  }
+
+  return are_reports_empty ? 0 : -1;
 }
 
 /**



More information about the Bf-blender-cvs mailing list