forked from bartvdbraak/blender
replace double prints in readfile.c with a BKE_reportf wrapper
This commit is contained in:
parent
d560b33f74
commit
05436e9a45
@ -39,6 +39,7 @@
|
|||||||
#include <fcntl.h> // for open
|
#include <fcntl.h> // for open
|
||||||
#include <string.h> // for strrchr strncmp strstr
|
#include <string.h> // for strrchr strncmp strstr
|
||||||
#include <math.h> // for fabs
|
#include <math.h> // for fabs
|
||||||
|
#include <stdarg.h> /* for va_start/end */
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <unistd.h> // for read close
|
#include <unistd.h> // for read close
|
||||||
@ -249,6 +250,31 @@ static void *read_struct(FileData *fd, BHead *bh, const char *blockname);
|
|||||||
static void direct_link_modifiers(FileData *fd, ListBase *lb);
|
static void direct_link_modifiers(FileData *fd, ListBase *lb);
|
||||||
static void convert_tface_mt(FileData *fd, Main *main);
|
static void convert_tface_mt(FileData *fd, Main *main);
|
||||||
|
|
||||||
|
/* this function ensures that reports are printed,
|
||||||
|
* in the case of libraray linking errors this is important!
|
||||||
|
*
|
||||||
|
* bit kludge but better then doubling up on prints,
|
||||||
|
* we could alternatively have a versions of a report function which foces printing - campbell
|
||||||
|
*/
|
||||||
|
static void BKE_reportf_wrap(ReportList *reports, ReportType type, const char *format, ...)
|
||||||
|
{
|
||||||
|
char fixed_buf[1024]; /* should be long enough */
|
||||||
|
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, format);
|
||||||
|
vsnprintf(fixed_buf, sizeof(fixed_buf), format, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
fixed_buf[sizeof(fixed_buf) - 1] = '\0';
|
||||||
|
|
||||||
|
BKE_report(reports, type, fixed_buf);
|
||||||
|
|
||||||
|
if(G.background==0) {
|
||||||
|
printf("%s\n", fixed_buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static OldNewMap *oldnewmap_new(void)
|
static OldNewMap *oldnewmap_new(void)
|
||||||
{
|
{
|
||||||
OldNewMap *onm= MEM_callocN(sizeof(*onm), "OldNewMap");
|
OldNewMap *onm= MEM_callocN(sizeof(*onm), "OldNewMap");
|
||||||
@ -4115,8 +4141,9 @@ static void lib_link_object(FileData *fd, Main *main)
|
|||||||
ob= ob->id.next;
|
ob= ob->id.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(warn)
|
if(warn) {
|
||||||
BKE_report(fd->reports, RPT_WARNING, "Warning in console");
|
BKE_report(fd->reports, RPT_WARNING, "Warning in console");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4697,8 +4724,9 @@ static void lib_link_scene(FileData *fd, Main *main)
|
|||||||
base->object= newlibadr_us(fd, sce->id.lib, base->object);
|
base->object= newlibadr_us(fd, sce->id.lib, base->object);
|
||||||
|
|
||||||
if(base->object==NULL) {
|
if(base->object==NULL) {
|
||||||
BKE_reportf(fd->reports, RPT_ERROR, "LIB ERROR: Object lost from scene:'%s\'\n", sce->id.name+2);
|
BKE_reportf_wrap(fd->reports, RPT_ERROR,
|
||||||
if(G.background==0) printf("LIB ERROR: base removed from scene:'%s\'\n", sce->id.name+2);
|
"LIB ERROR: Object lost from scene:'%s\'\n",
|
||||||
|
sce->id.name+2);
|
||||||
BLI_remlink(&sce->base, base);
|
BLI_remlink(&sce->base, base);
|
||||||
if(base==sce->basact) sce->basact= NULL;
|
if(base==sce->basact) sce->basact= NULL;
|
||||||
MEM_freeN(base);
|
MEM_freeN(base);
|
||||||
@ -5798,8 +5826,9 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
|
|||||||
for(newmain= fd->mainlist.first; newmain; newmain= newmain->next) {
|
for(newmain= fd->mainlist.first; newmain; newmain= newmain->next) {
|
||||||
if(newmain->curlib) {
|
if(newmain->curlib) {
|
||||||
if(BLI_path_cmp(newmain->curlib->filepath, lib->filepath) == 0) {
|
if(BLI_path_cmp(newmain->curlib->filepath, lib->filepath) == 0) {
|
||||||
printf("Fixed error in file; multiple instances of lib:\n %s\n", lib->filepath);
|
BKE_reportf_wrap(fd->reports, RPT_WARNING,
|
||||||
BKE_reportf(fd->reports, RPT_WARNING, "Library '%s', '%s' had multiple instances, save and reload!", lib->name, lib->filepath);
|
"Library '%s', '%s' had multiple instances, save and reload!",
|
||||||
|
lib->name, lib->filepath);
|
||||||
|
|
||||||
change_idid_adr(&fd->mainlist, fd, lib, newmain->curlib);
|
change_idid_adr(&fd->mainlist, fd, lib, newmain->curlib);
|
||||||
// change_idid_adr_fd(fd, lib, newmain->curlib);
|
// change_idid_adr_fd(fd, lib, newmain->curlib);
|
||||||
@ -12840,12 +12869,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
|||||||
|
|
||||||
for (ob= main->object.first; ob; ob= ob->id.next) {
|
for (ob= main->object.first; ob; ob= ob->id.next) {
|
||||||
if (ob->type == OB_FONT) {
|
if (ob->type == OB_FONT) {
|
||||||
for (prop=ob->prop.first;prop;prop=prop->next) {
|
prop = get_ob_property(ob, "Text");
|
||||||
if (strcmp(prop->name, "Text") == 0) {
|
if (prop) {
|
||||||
BKE_reportf(fd->reports, RPT_WARNING, "Game property name conflict in object: \"%s\".\nText objects reserve the [\"Text\"] game property to change their content through Logic Bricks.\n", ob->id.name+2);
|
BKE_reportf_wrap(fd->reports, RPT_WARNING,
|
||||||
if(G.background==0) printf("Game property conflict in object: \"%s\". Texts reserve the [\"Text\"] game property to change their content through Logic Bricks.\n", ob->id.name+2);
|
"Game property name conflict in object: \"%s\".\nText objects reserve the "
|
||||||
break;
|
"[\"Text\"] game property to change their content through Logic Bricks.\n",
|
||||||
}
|
ob->id.name+2);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -14302,8 +14332,9 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
|
|||||||
if(fd==NULL) {
|
if(fd==NULL) {
|
||||||
|
|
||||||
/* printf and reports for now... its important users know this */
|
/* printf and reports for now... its important users know this */
|
||||||
BKE_reportf(basefd->reports, RPT_INFO, "read library: '%s', '%s'\n", mainptr->curlib->filepath, mainptr->curlib->name);
|
BKE_reportf_wrap(basefd->reports, RPT_INFO,
|
||||||
if(!G.background && basefd->reports) printf("read library: '%s', '%s'\n", mainptr->curlib->filepath, mainptr->curlib->name);
|
"read library: '%s', '%s'\n",
|
||||||
|
mainptr->curlib->filepath, mainptr->curlib->name);
|
||||||
|
|
||||||
fd= blo_openblenderfile(mainptr->curlib->filepath, basefd->reports);
|
fd= blo_openblenderfile(mainptr->curlib->filepath, basefd->reports);
|
||||||
|
|
||||||
@ -14348,8 +14379,9 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
|
|||||||
else mainptr->curlib->filedata= NULL;
|
else mainptr->curlib->filedata= NULL;
|
||||||
|
|
||||||
if (fd==NULL) {
|
if (fd==NULL) {
|
||||||
BKE_reportf(basefd->reports, RPT_ERROR, "Can't find lib '%s'\n", mainptr->curlib->filepath);
|
BKE_reportf_wrap(basefd->reports, RPT_ERROR,
|
||||||
if(!G.background && basefd->reports) printf("ERROR: can't find lib %s \n", mainptr->curlib->filepath);
|
"Can't find lib '%s'\n",
|
||||||
|
mainptr->curlib->filepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(fd) {
|
if(fd) {
|
||||||
@ -14366,8 +14398,10 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
|
|||||||
|
|
||||||
append_id_part(fd, mainptr, id, &realid);
|
append_id_part(fd, mainptr, id, &realid);
|
||||||
if (!realid) {
|
if (!realid) {
|
||||||
BKE_reportf(fd->reports, RPT_ERROR, "LIB ERROR: %s:'%s' missing from '%s'\n", BKE_idcode_to_name(GS(id->name)), id->name+2, mainptr->curlib->filepath);
|
BKE_reportf_wrap(fd->reports, RPT_ERROR,
|
||||||
if(!G.background && basefd->reports) printf("LIB ERROR: %s:'%s' missing from '%s'\n", BKE_idcode_to_name(GS(id->name)), id->name+2, mainptr->curlib->filepath);
|
"LIB ERROR: %s:'%s' missing from '%s'\n",
|
||||||
|
BKE_idcode_to_name(GS(id->name)),
|
||||||
|
id->name+2, mainptr->curlib->filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
change_idid_adr(mainlist, basefd, id, realid);
|
change_idid_adr(mainlist, basefd, id, realid);
|
||||||
@ -14403,13 +14437,9 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
|
|||||||
ID *idn= id->next;
|
ID *idn= id->next;
|
||||||
if(id->flag & LIB_READ) {
|
if(id->flag & LIB_READ) {
|
||||||
BLI_remlink(lbarray[a], id);
|
BLI_remlink(lbarray[a], id);
|
||||||
BKE_reportf(basefd->reports, RPT_ERROR,
|
BKE_reportf_wrap(basefd->reports, RPT_ERROR,
|
||||||
"LIB ERROR: %s:'%s' unread libblock missing from '%s'\n",
|
"LIB ERROR: %s:'%s' unread libblock missing from '%s'\n",
|
||||||
BKE_idcode_to_name(GS(id->name)), id->name+2, mainptr->curlib->filepath);
|
BKE_idcode_to_name(GS(id->name)), id->name+2, mainptr->curlib->filepath);
|
||||||
if (!G.background && basefd->reports) {
|
|
||||||
printf("LIB ERROR: %s:'%s' unread libblock missing from '%s'\n",
|
|
||||||
BKE_idcode_to_name(GS(id->name)), id->name+2, mainptr->curlib->filepath);
|
|
||||||
}
|
|
||||||
change_idid_adr(mainlist, basefd, id, NULL);
|
change_idid_adr(mainlist, basefd, id, NULL);
|
||||||
|
|
||||||
MEM_freeN(id);
|
MEM_freeN(id);
|
||||||
|
Loading…
Reference in New Issue
Block a user