Cleanup: readfile: cleanup a bit error messages.

Printing those twice is already not so nice, but at least let's try to print same thing,
and avoid repetition of 'ERROR' in it.
This commit is contained in:
Bastien Montagne 2015-11-13 15:26:22 +01:00
parent 6d497d4f3b
commit 400e8c6449
3 changed files with 13 additions and 11 deletions

View File

@ -66,6 +66,8 @@ Report *BKE_reports_last_displayable(ReportList *reports);
bool BKE_reports_contain(ReportList *reports, ReportType level);
const char *BKE_report_type_str(ReportType type);
bool BKE_report_write_file_fp(FILE *fp, ReportList *reports, const char *header);
bool BKE_report_write_file(const char *filepath, ReportList *reports, const char *header);

View File

@ -43,7 +43,7 @@
#include "BKE_report.h"
#include "BKE_global.h" /* G.background only */
static const char *report_type_str(int type)
const char *BKE_report_type_str(ReportType type)
{
switch (type) {
case RPT_DEBUG:
@ -109,7 +109,7 @@ void BKE_report(ReportList *reports, ReportType type, const char *_message)
/* in background mode always print otherwise there are cases the errors wont 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))) {
printf("%s: %s\n", report_type_str(type), message);
printf("%s: %s\n", BKE_report_type_str(type), message);
fflush(stdout); /* this ensures the message is printed before a crash */
}
@ -117,7 +117,7 @@ void BKE_report(ReportList *reports, ReportType type, const char *_message)
char *message_alloc;
report = MEM_callocN(sizeof(Report), "Report");
report->type = type;
report->typestr = report_type_str(type);
report->typestr = BKE_report_type_str(type);
len = strlen(message);
message_alloc = MEM_callocN(sizeof(char) * (len + 1), "ReportMessage");
@ -136,7 +136,7 @@ void BKE_reportf(ReportList *reports, ReportType type, const char *_format, ...)
const char *format = TIP_(_format);
if (G.background || !reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) {
printf("%s: ", report_type_str(type));
printf("%s: ", BKE_report_type_str(type));
va_start(args, _format);
vprintf(format, args);
va_end(args);
@ -157,7 +157,7 @@ void BKE_reportf(ReportList *reports, ReportType type, const char *_format, ...)
BLI_dynstr_free(ds);
report->type = type;
report->typestr = report_type_str(type);
report->typestr = BKE_report_type_str(type);
BLI_addtail(&reports->list, report);
}

View File

@ -255,7 +255,7 @@ void blo_reportf_wrap(ReportList *reports, ReportType type, const char *format,
BKE_report(reports, type, fixed_buf);
if (G.background == 0) {
printf("%s\n", fixed_buf);
printf("%s: %s\n", BKE_report_type_str(type), fixed_buf);
}
}
@ -5578,7 +5578,7 @@ static void lib_link_scene(FileData *fd, Main *main)
base->object = newlibadr_us(fd, sce->id.lib, base->object);
if (base->object == NULL) {
blo_reportf_wrap(fd->reports, RPT_WARNING, TIP_("LIB ERROR: object lost from scene: '%s'"),
blo_reportf_wrap(fd->reports, RPT_WARNING, TIP_("LIB: object lost from scene: '%s'"),
sce->id.name + 2);
BLI_remlink(&sce->base, base);
if (base == sce->basact) sce->basact = NULL;
@ -8547,7 +8547,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
if (ptr->curlib == NULL) {
const char *idname= bhead_id_name(fd, bhead);
blo_reportf_wrap(fd->reports, RPT_WARNING, TIP_("LIB ERROR: Data refers to main .blend file: '%s' from %s"),
blo_reportf_wrap(fd->reports, RPT_WARNING, TIP_("LIB: Data refers to main .blend file: '%s' from %s"),
idname, mainvar->curlib->filepath);
return;
}
@ -9777,7 +9777,7 @@ static void link_id_part(ReportList *reports, FileData *fd, Main *mainvar, ID *i
else {
blo_reportf_wrap(
reports, RPT_WARNING,
TIP_("LIB ERROR: %s: '%s' missing from '%s', parent '%s'"),
TIP_("LIB: %s: '%s' missing from '%s', parent '%s'"),
BKE_idcode_to_name(GS(id->name)),
id->name + 2,
mainvar->curlib->filepath,
@ -10084,8 +10084,8 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
BLI_assert(0);
BLI_remlink(lbarray[a], id);
blo_reportf_wrap(
basefd->reports, RPT_WARNING,
TIP_("LIB ERROR: %s: '%s' unread lib block missing from '%s', parent '%s' - "
basefd->reports, RPT_ERROR,
TIP_("LIB: %s: '%s' unread lib block missing from '%s', parent '%s' - "
"Please file a bug report if you see this message"),
BKE_idcode_to_name(GS(id->name)),
id->name + 2,