[Bf-blender-cvs] [42df095e4bd] soc-2020-info-editor: Fix report logging
Mateusz GrzeliÅski
noreply at git.blender.org
Wed Jul 8 15:14:47 CEST 2020
Commit: 42df095e4bdc52af64a29b88b99d837c6d2d1aea
Author: Mateusz Grzeliński
Date: Wed Jul 8 11:14:24 2020 +0200
Branches: soc-2020-info-editor
https://developer.blender.org/rB42df095e4bdc52af64a29b88b99d837c6d2d1aea
Fix report logging
- do not return NULL from BKE_reports_sprintf, it is too hard to handle memory free-ing
- fix: convert clog info to verbose
===================================================================
M source/blender/blenkernel/intern/report.c
M source/blender/modifiers/intern/MOD_datatransfer.c
===================================================================
diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c
index f37a718078d..e08c237795a 100644
--- a/source/blender/blenkernel/intern/report.c
+++ b/source/blender/blenkernel/intern/report.c
@@ -152,12 +152,12 @@ void BKE_report(ReportList *reports, ReportType type, const char *_message)
int len;
const char *message = TIP_(_message);
- CLOG_INFO(&LOG,
- report_type_to_verbosity(type),
- "ReportList(%p):%s: %s",
- reports,
- BKE_report_type_str(type),
- message);
+ CLOG_VERBOSE(&LOG,
+ report_type_to_verbosity(type),
+ "ReportList(%p):%s: %s",
+ reports,
+ BKE_report_type_str(type),
+ message);
if (reports) {
char *message_alloc;
@@ -192,12 +192,12 @@ void BKE_reportf(ReportList *reports, ReportType type, const char *_format, ...)
*/
if (CLOG_CHECK_IN_USE(&LOG)) {
char *message_cstring = BLI_dynstr_get_cstring(message);
- CLOG_INFO(&LOG,
- report_type_to_verbosity(type),
- "ReportList(%p):%s: %s",
- reports,
- BKE_report_type_str(type),
- message_cstring);
+ CLOG_VERBOSE(&LOG,
+ report_type_to_verbosity(type),
+ "ReportList(%p):%s: %s",
+ reports,
+ BKE_report_type_str(type),
+ message_cstring);
MEM_freeN(message_cstring);
}
@@ -283,31 +283,37 @@ void BKE_report_print_level_set(ReportList *reports, ReportType level)
reports->printlevel = level;
}
-/** return pretty printed reports with minimum level (level=0 - print all) or NULL */
+/** return pretty printed reports with minimum level (level=0 - print all) */
char *BKE_reports_sprintfN(ReportList *reports, ReportType level)
{
Report *report;
DynStr *ds;
char *cstring;
- if (!reports || !reports->list.first) {
- return NULL;
- }
-
ds = BLI_dynstr_new();
- for (report = reports->list.first; report; report = report->next) {
- if (report->type >= level) {
- BLI_dynstr_appendf(ds, "%s: %s\n", report->typestr, report->message);
- }
- }
- if (BLI_dynstr_get_len(ds)) {
+ if (reports == NULL) {
+ BLI_dynstr_append(ds, "ReportList(<NULL>):");
cstring = BLI_dynstr_get_cstring(ds);
+ BLI_dynstr_free(ds);
+ return cstring;
+ }
+ else {
+ BLI_dynstr_appendf(ds, "ReportList(%p):", reports);
+ }
+
+ if (BLI_listbase_is_empty(&reports->list)) {
+ BLI_dynstr_append(ds, " Empty list");
}
else {
- cstring = NULL;
+ for (report = reports->list.first; report; report = report->next) {
+ if (report->type >= level) {
+ BLI_dynstr_appendf(ds, "%s: %s\n", report->typestr, report->message);
+ }
+ }
}
+ cstring = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
return cstring;
}
diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c
index bb225a3dfb4..11925d41b03 100644
--- a/source/blender/modifiers/intern/MOD_datatransfer.c
+++ b/source/blender/modifiers/intern/MOD_datatransfer.c
@@ -229,8 +229,9 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
&reports);
if (BKE_reports_contain(&reports, RPT_ERROR)) {
- // todo is it mem leak?
- BKE_modifier_set_error(md, "%s", BKE_reports_sprintfN(&reports, RPT_ERROR));
+ char *pretty_reports = BKE_reports_sprintfN(&reports, RPT_ERROR);
+ BKE_modifier_set_error(md, "%s", pretty_reports);
+ MEM_freeN(pretty_reports);
}
else if ((dtmd->data_types & DT_TYPE_LNOR) && !(me->flag & ME_AUTOSMOOTH)) {
BKE_modifier_set_error((ModifierData *)dtmd, "Enable 'Auto Smooth' in Object Data Properties");
More information about the Bf-blender-cvs
mailing list