2.5: Change blenloader module to use the Report system for reporting errors.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 19 Dec 2008 00:50:21 +0000 (00:50 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 19 Dec 2008 00:50:21 +0000 (00:50 +0000)
16 files changed:
source/blender/blenkernel/BKE_report.h
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/report.c
source/blender/blenloader/BLO_readfile.h
source/blender/blenloader/BLO_writefile.h
source/blender/blenloader/intern/readblenentry.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/readfile.h
source/blender/blenloader/intern/writefile.c
source/blender/makesdna/DNA_fileglobal_types.h
source/blender/readblenfile/BLO_readblenfile.h
source/blender/readblenfile/intern/BLO_readblenfile.c
source/blender/windowmanager/intern/wm_files.c
source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
source/gameengine/GamePlayer/common/GPC_Engine.cpp
source/gameengine/GamePlayer/ghost/GPG_ghost.cpp

index 39a50769234be691eaf3fc907f85561df1ca451e..f87910d78721289f7274cec974a005e2c6b61170 100644 (file)
@@ -48,7 +48,8 @@ typedef enum ReportType {
 
 enum ReportListFlags {
        RPT_PRINT = 1,
-       RPT_STORE = 2
+       RPT_STORE = 2,
+       RPT_HAS_ERROR = 4
 };
 
 typedef struct Report {
@@ -60,20 +61,24 @@ typedef struct Report {
 
 typedef struct ReportList {
        ListBase list;
-       ReportType level;
-       int flags;
+       ReportType printlevel;
+       ReportType storelevel;
+       int flag;
 } ReportList;
 
-void BKE_report_list_init(ReportList *reports, int flag);
-void BKE_report_list_clear(ReportList *reports);
+void BKE_reports_init(ReportList *reports, int flag);
+void BKE_reports_clear(ReportList *reports);
 
 void BKE_report(ReportList *reports, ReportType type, const char *message);
 void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...);
 
-ReportType BKE_report_level(ReportList *reports);
-void BKE_report_level_set(ReportList *reports, ReportType level);
+ReportType BKE_report_print_level(ReportList *reports);
+void BKE_report_print_level_set(ReportList *reports, ReportType level);
 
-int BKE_report_has_error(ReportList *reports);
+ReportType BKE_report_store_level(ReportList *reports);
+void BKE_report_store_level_set(ReportList *reports, ReportType level);
+
+void BKE_reports_print(ReportList *reports, ReportType level);
 
 #ifdef __cplusplus
 }
index b891e75a71b9a62b93e2a1be218acc7dccee89d3..ed2b8238dae6c3b9bb5630a72465c0daefef9980 100644 (file)
@@ -77,6 +77,7 @@
 #include "BKE_main.h"
 #include "BKE_node.h"
 #include "BKE_object.h"
+#include "BKE_report.h"
 #include "BKE_scene.h"
 #include "BKE_screen.h"
 #include "BKE_sound.h"
@@ -435,11 +436,13 @@ static void handle_subversion_warning(Main *main)
 
 int BKE_read_file(bContext *C, char *dir, void *unused) 
 {
-       BlendReadError bre;
+       ReportList reports;
        BlendFileData *bfd;
        int retval= 1;
        
-       bfd= BLO_read_from_file(dir, &bre);
+       BKE_reports_init(&reports, RPT_STORE);
+
+       bfd= BLO_read_from_file(dir, &reports);
        if (bfd) {
                if(bfd->user) retval= 2;
                
@@ -450,38 +453,48 @@ int BKE_read_file(bContext *C, char *dir, void *unused)
        else {
 // XXX         error("Loading %s failed: %s", dir, BLO_bre_as_string(bre));
        }
+
+       BKE_reports_clear(&reports);
                
        return (bfd?retval:0);
 }
 
 int BKE_read_file_from_memory(bContext *C, char* filebuf, int filelength, void *unused)
 {
-       BlendReadError bre;
+       ReportList reports;
        BlendFileData *bfd;
-                       
-       bfd= BLO_read_from_memory(filebuf, filelength, &bre);
+
+       BKE_reports_init(&reports, RPT_STORE);
+
+       bfd= BLO_read_from_memory(filebuf, filelength, &reports);
        if (bfd) {
                setup_app_data(C, bfd, "<memory2>");
        } else {
 // XXX         error("Loading failed: %s", BLO_bre_as_string(bre));
        }
                
+       BKE_reports_clear(&reports);
+
        return (bfd?1:0);
 }
 
 /* memfile is the undo buffer */
 int BKE_read_file_from_memfile(bContext *C, MemFile *memfile)
 {
-       BlendReadError bre;
+       ReportList reports;
        BlendFileData *bfd;
        
-       bfd= BLO_read_from_memfile(G.sce, memfile, &bre);
+       BKE_reports_init(&reports, RPT_STORE);
+
+       bfd= BLO_read_from_memfile(G.sce, memfile, &reports);
        if (bfd) {
                setup_app_data(C, bfd, "<memory1>");
        } else {
 // XXX         error("Loading failed: %s", BLO_bre_as_string(bre));
        }
                
+       BKE_reports_clear(&reports);
+
        return (bfd?1:0);
 }
 
@@ -568,8 +581,9 @@ void BKE_write_undo(bContext *C, char *name)
 
        /* disk save version */
        if(UNDO_DISK) {
+               ReportList reports;
                static int counter= 0;
-               char *err, tstr[FILE_MAXDIR+FILE_MAXFILE];
+               char tstr[FILE_MAXDIR+FILE_MAXFILE];
                char numstr[32];
                
                /* calculate current filename */
@@ -579,18 +593,22 @@ void BKE_write_undo(bContext *C, char *name)
                sprintf(numstr, "%d.blend", counter);
                BLI_make_file_string("/", tstr, btempdir, numstr);
        
-               success= BLO_write_file(C, tstr, G.fileflags, &err);
+               BKE_reports_init(&reports, 0);
+               success= BLO_write_file(C, tstr, G.fileflags, &reports);
+               BKE_reports_clear(&reports);
                
                strcpy(curundo->str, tstr);
        }
        else {
+               ReportList reports;
                MemFile *prevfile=NULL;
-               char *err;
                
                if(curundo->prev) prevfile= &(curundo->prev->memfile);
                
                memused= MEM_get_memory_in_use();
-               success= BLO_write_file_mem(C, prevfile, &curundo->memfile, G.fileflags, &err);
+               BKE_reports_init(&reports, 0);
+               success= BLO_write_file_mem(C, prevfile, &curundo->memfile, G.fileflags, &reports);
+               BKE_reports_clear(&reports);
                curundo->undosize= MEM_get_memory_in_use() - memused;
        }
 
index 569377a1c2fa937459ae62775effc779a7574b3c..12fbaf806d5bd0add83b07d2ef60eef1ad5ed4e4 100644 (file)
@@ -57,15 +57,16 @@ static char *report_type_str(int type)
        }
 }
 
-void BKE_report_list_init(ReportList *reports, int flags)
+void BKE_reports_init(ReportList *reports, int flag)
 {
        memset(reports, 0, sizeof(ReportList));
 
-       reports->level= RPT_WARNING;
-       reports->flags= flags;
+       reports->storelevel= RPT_WARNING;
+       reports->printlevel= RPT_WARNING;
+       reports->flag= flag;
 }
 
-void BKE_report_list_clear(ReportList *reports)
+void BKE_reports_clear(ReportList *reports)
 {
        Report *report;
 
@@ -80,15 +81,18 @@ void BKE_report(ReportList *reports, ReportType type, const char *message)
        Report *report;
        int len;
 
-       if(!reports || type < reports->level)
+       if(!reports)
                return;
+       
+       if(type >= RPT_ERROR)
+               reports->flag |= RPT_HAS_ERROR;
 
-       if(reports->flags & RPT_PRINT) {
+       if((reports->flag & RPT_PRINT) && (type >= reports->printlevel)) {
                printf("%s: %s\n", report_type_str(type), message);
                fflush(stdout); /* this ensures the message is printed before a crash */
        }
 
-       if(reports->flags & RPT_STORE) {
+       if((reports->flag & RPT_STORE) && (type >= reports->storelevel)) {
                report= MEM_callocN(sizeof(Report), "Report");
                report->type= type;
                report->typestr= report_type_str(type);
@@ -108,17 +112,20 @@ void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...)
        char *message;
        int len= 256, maxlen= 65536, retval;
 
-       if(!reports || type < reports->level)
+       if(!reports)
                return;
 
-       if(reports->flags & RPT_PRINT) {
+       if(type >= RPT_ERROR)
+               reports->flag |= RPT_HAS_ERROR;
+
+       if((reports->flag & RPT_PRINT) && (type >= reports->printlevel)) {
                va_start(args, format);
                vprintf(format, args);
                va_end(args);
                fflush(stdout); /* this ensures the message is printed before a crash */
        }
 
-       if(reports->flags & RPT_STORE) {
+       if((reports->flag & RPT_STORE) && (type >= reports->storelevel)) {
                while(1) {
                        message= MEM_callocN(sizeof(char)*len+1, "ReportMessage");
 
@@ -160,27 +167,37 @@ void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...)
        }
 }
 
-ReportType BKE_report_level(ReportList *reports)
+ReportType BKE_report_print_level(ReportList *reports)
 {
-       return reports->level;
+       return reports->printlevel;
 }
 
-void BKE_report_level_set(ReportList *reports, ReportType level)
+void BKE_report_print_level_set(ReportList *reports, ReportType level)
 {
-       reports->level= level;
+       reports->printlevel= level;
 }
 
-int BKE_report_has_error(ReportList *reports)
+ReportType BKE_report_store_level(ReportList *reports)
+{
+       return reports->storelevel;
+}
+
+void BKE_report_store_level_set(ReportList *reports, ReportType level)
+{
+       reports->storelevel= level;
+}
+
+void BKE_reports_print(ReportList *reports, ReportType level)
 {
        Report *report;
 
        if(!reports)
-               return 0;
-
-       for(report=reports->list.first; report; report=report->next)
-               if(report->type >= RPT_ERROR)
-                       return 1;
+               return;
        
-       return 0;
+       for(report=reports->list.first; report; report=report->next)
+               if(report->type >= level)
+                       printf("%s: %s\n", report->typestr, report->message);
+
+       fflush(stdout);
 }
 
index 1219b1ba0c587cf8955530a04a44328e868fbc94..38f8be58bf6f9cfe3034e6c400958efaae61bf11 100644 (file)
 extern "C" {
 #endif
 
-struct SpaceFile;
-struct SpaceImaSel;
+struct bScreen;
+struct direntry;
 struct FileList;
 struct LinkNode;
 struct Main;
-struct UserDef;
-struct bScreen;
-struct Scene;
 struct MemFile;
-struct direntry;
+struct ReportList;
+struct Scene;
+struct SpaceFile;
+struct SpaceImaSel;
+struct UserDef;
 
 typedef struct BlendHandle     BlendHandle;
 
@@ -53,29 +54,6 @@ typedef enum BlenFileType {
        BLENFILETYPE_RUNTIME= 3
 } BlenFileType;
 
-typedef enum {
-       BRE_NONE, 
-       
-       BRE_UNABLE_TO_OPEN, 
-       BRE_UNABLE_TO_READ, 
-
-       BRE_OUT_OF_MEMORY, 
-       BRE_INTERNAL_ERROR, 
-
-       BRE_NOT_A_BLEND, 
-       BRE_NOT_A_PUBFILE,
-       BRE_INCOMPLETE, 
-       BRE_CORRUPT, 
-       
-       BRE_TOO_NEW, 
-       BRE_NOT_ALLOWED, 
-       
-       BRE_NO_SCREEN, 
-       BRE_NO_SCENE, 
-       
-       BRE_INVALID
-} BlendReadError;
-
 typedef struct BlendFileData {
        struct Main*    main;
        struct UserDef* user;
@@ -93,46 +71,33 @@ typedef struct BlendFileData {
 
        /**
         * Open a blender file from a pathname. The function
-        * returns NULL and sets the @a error_r argument if
+        * returns NULL and sets a report in the list if
         * it cannot open the file.
         * 
         * @param file The path of the file to open.
-        * @param error_r If the return value is NULL, an error
-        * code indicating the cause of the failure.
+        * @param reports If the return value is NULL, errors
+        * indicating the cause of the failure.
         * @return The data of the file.
         */
-BlendFileData* BLO_read_from_file              (char *file, BlendReadError *error_r);
+BlendFileData* BLO_read_from_file              (char *file, struct ReportList *reports);
 
        /**
         * Open a blender file from memory. The function
-        * returns NULL and sets the @a error_r argument if
+        * returns NULL and sets a report in the list if
         * it cannot open the file.
         * 
         * @param mem The file data.
         * @param memsize The length of @a mem.
-        * @param error_r If the return value is NULL, an error
-        * code indicating the cause of the failure.
+        * @param reports If the return value is NULL, errors
+        * indicating the cause of the failure.
         * @return The data of the file.
         */
-BlendFileData* BLO_read_from_memory(void *mem, int memsize, BlendReadError *error_r);
+BlendFileData* BLO_read_from_memory(void *mem, int memsize, struct ReportList *reports);
 
 /**
  * file name is current file, only for retrieving library data */
 
-BlendFileData *BLO_read_from_memfile(const char *filename, struct MemFile *memfile, BlendReadError *error_r);
-
-/**
- * Convert a BlendReadError to a human readable string.
- * The string is static and does not need to be free'd.
- * 
- * @param error The error to return a string for.
- * @return A static human readable string representation
- * of @a error.
- */
-       char*
-BLO_bre_as_string(
-       BlendReadError error);
+BlendFileData *BLO_read_from_memfile(const char *filename, struct MemFile *memfile, struct ReportList *reports);
 
 /**
  * Free's a BlendFileData structure and _all_ the
@@ -239,7 +204,7 @@ void BLO_library_append_(BlendHandle **libfiledata, struct direntry* filelist, i
                                                 char *dir, char* file, short flag, int idcode, struct Scene *scene);
 void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, int idcode, short flag, struct Scene *scene);
 
-BlendFileData* blo_read_blendafterruntime(int file, char *name, int actualsize, BlendReadError *error_r);
+BlendFileData* blo_read_blendafterruntime(int file, char *name, int actualsize, struct ReportList *reports);
 
 #ifdef __cplusplus
 } 
index 0b88cb1fb77c771ba1bfb87899e6e694b1311cac..8205a43f39f0f186a38b13e9e5f281edd1ea4bfd 100644 (file)
 
 struct MemFile;
 struct bContext;
+struct ReportList;
 
-extern int BLO_write_file(struct bContext *C, char *dir, int write_flags, char **error_r);
+extern int BLO_write_file(struct bContext *C, char *dir, int write_flags, struct ReportList *reports);
 extern int BLO_write_file_mem(struct bContext *C, struct MemFile *compare, struct MemFile *current, 
-                                                         int write_flags, char **error_r);
-extern void BLO_write_runtime(struct bContext *C, char *file, char *exename);
+                                                         int write_flags, struct ReportList *reports);
+extern int BLO_write_runtime(struct bContext *C, char *file, char *exename, struct ReportList *reports);
 
 #endif
 
index d5f5bb663abdfd4c124ac52a70e68d3a7e3192ee..d7acfc7eed045304be84eb2089743764202dcaab 100644 (file)
@@ -55,6 +55,7 @@
 #include "BKE_main.h"
 #include "BKE_global.h"
 #include "BKE_library.h" // for free_main
+#include "BKE_report.h"
 
 #include "BLO_readfile.h"
 #include "BLO_undofile.h"
@@ -166,9 +167,14 @@ int BLO_idcode_from_name(char *name)
         
 BlendHandle *BLO_blendhandle_from_file(char *file) 
 {
-       BlendReadError err;
+       ReportList reports;
+       BlendHandle *bh;
 
-       return (BlendHandle*) blo_openblenderfile(file, &err);
+       BKE_reports_init(&reports, 0);
+       bh= (BlendHandle*)blo_openblenderfile(file, &reports);
+       BKE_reports_clear(&reports);
+
+       return bh;
 }
 
 void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp) 
@@ -318,14 +324,14 @@ void BLO_blendhandle_close(BlendHandle *bh) {
 
        /**********/
 
-BlendFileData *BLO_read_from_file(char *file, BlendReadError *error_r) 
+BlendFileData *BLO_read_from_file(char *file, ReportList *reports)
 {
        BlendFileData *bfd = NULL;
        FileData *fd;
                
-       fd = blo_openblenderfile(file, error_r);
+       fd = blo_openblenderfile(file, reports);
        if (fd) {
-               bfd= blo_read_file_internal(fd, error_r);
+               bfd= blo_read_file_internal(fd, reports);
                if (bfd) {
                        bfd->type= BLENFILETYPE_BLEND;
                        strncpy(bfd->main->name, file, sizeof(bfd->main->name)-1);
@@ -336,14 +342,14 @@ BlendFileData *BLO_read_from_file(char *file, BlendReadError *error_r)
        return bfd;     
 }
 
-BlendFileData *BLO_read_from_memory(void *mem, int memsize, BlendReadError *error_r) 
+BlendFileData *BLO_read_from_memory(void *mem, int memsize, ReportList *reports)
 {
        BlendFileData *bfd = NULL;
        FileData *fd;
                
-       fd = blo_openblendermemory(mem, memsize,  error_r);
+       fd = blo_openblendermemory(mem, memsize,  reports);
        if (fd) {
-               bfd= blo_read_file_internal(fd, error_r);
+               bfd= blo_read_file_internal(fd, reports);
                if (bfd) {
                        bfd->type= BLENFILETYPE_BLEND;
                        strcpy(bfd->main->name, "");
@@ -354,13 +360,13 @@ BlendFileData *BLO_read_from_memory(void *mem, int memsize, BlendReadError *erro
        return bfd;     
 }
 
-BlendFileData *BLO_read_from_memfile(const char *filename, MemFile *memfile, BlendReadError *error_r) 
+BlendFileData *BLO_read_from_memfile(const char *filename, MemFile *memfile, ReportList *reports)
 {
        BlendFileData *bfd = NULL;
        FileData *fd;
        ListBase mainlist;
        
-       fd = blo_openblendermemfile(memfile, error_r);
+       fd = blo_openblendermemfile(memfile, reports);
        if (fd) {
                strcpy(fd->filename, filename);
                
@@ -375,7 +381,7 @@ BlendFileData *BLO_read_from_memfile(const char *filename, MemFile *memfile, Ble
                /* makes lookup of existing images in G.main */
                blo_make_image_pointer_map(fd);
                
-               bfd= blo_read_file_internal(fd, error_r);
+               bfd= blo_read_file_internal(fd, reports);
                if (bfd) {
                        bfd->type= BLENFILETYPE_BLEND;
                        strcpy(bfd->main->name, "");
@@ -416,43 +422,3 @@ void BLO_blendfiledata_free(BlendFileData *bfd)
        MEM_freeN(bfd);
 }
 
-char *BLO_bre_as_string(BlendReadError error) 
-{
-       switch (error) {
-       case BRE_NONE:
-               return "No error";
-       
-       case BRE_UNABLE_TO_OPEN:
-               return "Unable to open";
-       case BRE_UNABLE_TO_READ:
-               return "Unable to read";
-               
-       case BRE_OUT_OF_MEMORY:
-               return "Out of memory";
-       case BRE_INTERNAL_ERROR:
-               return "<internal error>";
-
-       case BRE_NOT_A_BLEND:
-               return "File is not a Blender file";
-       case BRE_NOT_A_PUBFILE:
-               return "File is not a compressed, locked or signed Blender file";
-       case BRE_INCOMPLETE:
-               return "File incomplete";
-       case BRE_CORRUPT:
-               return "File corrupt";
-
-       case BRE_TOO_NEW:
-               return "File needs newer Blender version, please upgrade";
-       case BRE_NOT_ALLOWED:
-               return "File is locked";
-                                               
-       case BRE_NO_SCREEN:
-               return "File has no screen";
-       case BRE_NO_SCENE:
-               return "File has no scene";
-               
-       default:
-       case BRE_INVALID:
-               return "<invalid read error>";
-       }
-}
index 94c11e9d2e11233d6b6e6c8859290d740aa6dee7..296243834744fb91f14c4ae64d07ca7b178ad63d 100644 (file)
 #include "BKE_particle.h"
 #include "BKE_pointcache.h"
 #include "BKE_property.h" // for get_ob_property
+#include "BKE_report.h"
 #include "BKE_sca.h" // for init_actuator
 #include "BKE_scene.h"
 #include "BKE_softbody.h"      // sbNew()
@@ -925,19 +926,19 @@ static FileData *filedata_new(void)
        return fd;
 }
 
-static FileData *blo_decode_and_check(FileData *fd, BlendReadError *error_r)
+static FileData *blo_decode_and_check(FileData *fd, ReportList *reports)
 {
        decode_blender_header(fd);
 
        if (fd->flags & FD_FLAGS_FILE_OK) {
                if (!read_file_dna(fd)) {
-                       *error_r = BRE_INCOMPLETE;
+                       BKE_report(reports, RPT_ERROR, "File incomplete");
                        blo_freefiledata(fd);
                        fd= NULL;
                }
        } 
        else {
-               *error_r = BRE_NOT_A_BLEND;
+               BKE_report(reports, RPT_ERROR, "File is not a Blender file");
                blo_freefiledata(fd);
                fd= NULL;
        }
@@ -947,14 +948,14 @@ static FileData *blo_decode_and_check(FileData *fd, BlendReadError *error_r)
 
 /* cannot be called with relative paths anymore! */
 /* on each new library added, it now checks for the current FileData and expands relativeness */
-FileData *blo_openblenderfile(char *name, BlendReadError *error_r)
+FileData *blo_openblenderfile(char *name, ReportList *reports)
 {
        gzFile gzfile;
        
        gzfile= gzopen(name, "rb");
 
        if (NULL == gzfile) {
-               *error_r = BRE_UNABLE_TO_OPEN;
+               BKE_report(reports, RPT_ERROR, "Unable to open");
                return NULL;
        } else {
                FileData *fd = filedata_new();
@@ -964,14 +965,14 @@ FileData *blo_openblenderfile(char *name, BlendReadError *error_r)
                /* needed for library_append and read_libraries */
                BLI_strncpy(fd->filename, name, sizeof(fd->filename));
 
-               return blo_decode_and_check(fd, error_r);
+               return blo_decode_and_check(fd, reports);
        }
 }
 
-FileData *blo_openblendermemory(void *mem, int memsize, BlendReadError *error_r)
+FileData *blo_openblendermemory(void *mem, int memsize, ReportList *reports)
 {
        if (!mem || memsize<SIZEOFBLENDERHEADER) {
-               *error_r = mem?BRE_UNABLE_TO_READ:BRE_UNABLE_TO_OPEN;
+               BKE_report(reports, RPT_ERROR, (mem)? "Unable to read": "Unable to open");
                return NULL;
        } else {
                FileData *fd= filedata_new();
@@ -980,14 +981,14 @@ FileData *blo_openblendermemory(void *mem, int memsize, BlendReadError *error_r)
                fd->read= fd_read_from_memory;
                fd->flags|= FD_FLAGS_NOT_MY_BUFFER;
 
-               return blo_decode_and_check(fd, error_r);
+               return blo_decode_and_check(fd, reports);
        }
 }
 
-FileData *blo_openblendermemfile(MemFile *memfile, BlendReadError *error_r)
+FileData *blo_openblendermemfile(MemFile *memfile, ReportList *reports)
 {
        if (!memfile) {
-               *error_r = BRE_UNABLE_TO_OPEN;
+               BKE_report(reports, RPT_ERROR, "Unable to open");
                return NULL;
        } else {
                FileData *fd= filedata_new();
@@ -996,7 +997,7 @@ FileData *blo_openblendermemfile(MemFile *memfile, BlendReadError *error_r)
                fd->read= fd_read_from_memfile;
                fd->flags|= FD_FLAGS_NOT_MY_BUFFER;
 
-               return blo_decode_and_check(fd, error_r);
+               return blo_decode_and_check(fd, reports);
        }
 }
 
@@ -3102,7 +3103,8 @@ static void lib_link_object(FileData *fd, Main *main)
                ob= ob->id.next;
        }
 
-       if(warn); //XXX error("WARNING IN CONSOLE");
+       if(warn) //XXX error("WARNING IN CONSOLE");
+               BKE_report(fd->reports, RPT_WARNING, "Warning in console");
 }
 
 
@@ -4323,6 +4325,8 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
                                MEM_freeN(lib);
                                
                                //XXX error("Library had multiple instances, save and reload!");
+                               BKE_report(fd->reports, RPT_WARNING, "Library had multiple instances, save and reload!");
+
                                return;
                        }
                }
@@ -8350,7 +8354,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
        return bhead;
 }
 
-BlendFileData *blo_read_file_internal(FileData *fd, BlendReadError *error_r)
+BlendFileData *blo_read_file_internal(FileData *fd, ReportList *reports)
 {
        BHead *bhead= blo_firstbhead(fd);
        BlendFileData *bfd;
@@ -9538,9 +9542,13 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
                                FileData *fd= mainptr->curlib->filedata;
 
                                if(fd==NULL) {
-                                       BlendReadError err;
+                                       ReportList reports;
+
                                        printf("read library: lib %s\n", mainptr->curlib->name);
-                                       fd= blo_openblenderfile(mainptr->curlib->filename, &err);
+                                       BKE_reports_init(&reports, 0);
+                                       fd= blo_openblenderfile(mainptr->curlib->filename, &reports);
+                                       BKE_reports_clear(&reports);
+
                                        if (fd) {
                                                if (fd->libmap)
                                                        oldnewmap_free(fd->libmap);
@@ -9639,7 +9647,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
 
 /* reading runtime */
 
-BlendFileData *blo_read_blendafterruntime(int file, char *name, int actualsize, BlendReadError *error_r) 
+BlendFileData *blo_read_blendafterruntime(int file, char *name, int actualsize, ReportList *reports)
 {
        BlendFileData *bfd = NULL;
        FileData *fd = filedata_new();
@@ -9650,11 +9658,11 @@ BlendFileData *blo_read_blendafterruntime(int file, char *name, int actualsize,
        /* needed for library_append and read_libraries */
        BLI_strncpy(fd->filename, name, sizeof(fd->filename));
 
-       fd = blo_decode_and_check(fd, error_r);
+       fd = blo_decode_and_check(fd, reports);
        if (!fd)
                return NULL;
 
-       bfd= blo_read_file_internal(fd, error_r);
+       bfd= blo_read_file_internal(fd, reports);
        blo_freefiledata(fd);
 
        return bfd;
index 8547a4d96523b6c6d82a230642ab15339bba514e..f53f3c6c8837a875ea107cfba0ee8f17eef2d587 100644 (file)
@@ -35,6 +35,7 @@
 struct OldNewMap;
 struct MemFile;
 struct bheadsort;
+struct ReportList;
 
 typedef struct FileData {
        // linked list of BHeadN's
@@ -83,7 +84,7 @@ typedef struct FileData {
                 * data through streamglue.
                 */
        BlendFileData **bfd_r;
-       BlendReadError *error_r;
+       struct ReportList *reports;
 } FileData;
 
 typedef struct BHeadN {
@@ -106,11 +107,11 @@ struct Main;
 void blo_join_main(ListBase *mainlist);
 void blo_split_main(ListBase *mainlist, struct Main *main);
 
-BlendFileData *blo_read_file_internal( FileData *fd,  BlendReadError *error_r);
+BlendFileData *blo_read_file_internal( FileData *fd, struct ReportList *reports);
 
-FileData *blo_openblenderfile( char *name, BlendReadError *error_r);
-FileData *blo_openblendermemory( void *buffer, int buffersize, BlendReadError *error_r);
-FileData *blo_openblendermemfile(struct MemFile *memfile, BlendReadError *error_r);
+FileData *blo_openblenderfile( char *name, struct ReportList *reports);
+FileData *blo_openblendermemory( void *buffer, int buffersize, struct ReportList *reports);
+FileData *blo_openblendermemfile(struct MemFile *memfile, struct ReportList *reports);
 
 void blo_clear_proxy_pointers_from_lib(FileData *fd);
 void blo_make_image_pointer_map(FileData *fd);
index 1c44217bde0589787d6d078b588e392fa3b53769..6cd2d328c82fcfa5bf163c25c182677eef97e6e8 100644 (file)
@@ -155,6 +155,7 @@ Any case: direct data is ALWAYS after the lib block
 #include "BKE_main.h" // G.main
 #include "BKE_node.h"
 #include "BKE_packedFile.h" // for packAll
+#include "BKE_report.h"
 #include "BKE_screen.h" // for waitcursor
 #include "BKE_sequence.h"
 #include "BKE_sound.h" /* ... and for samples */
@@ -2110,7 +2111,7 @@ static int write_file_handle(bContext *C, int handle, MemFile *compare, MemFile
 }
 
 /* return: success (1) */
-int BLO_write_file(bContext *C, char *dir, int write_flags, char **error_r)
+int BLO_write_file(bContext *C, char *dir, int write_flags, ReportList *reports)
 {
        char userfilename[FILE_MAXDIR+FILE_MAXFILE];
        char tempname[FILE_MAXDIR+FILE_MAXFILE];
@@ -2120,7 +2121,7 @@ int BLO_write_file(bContext *C, char *dir, int write_flags, char **error_r)
 
        file = open(tempname,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
        if(file == -1) {
-               *error_r= "Unable to open";
+               BKE_report(reports, RPT_ERROR, "Unable to open file for writing.");
                return 0;
        }
 
@@ -2139,23 +2140,23 @@ int BLO_write_file(bContext *C, char *dir, int write_flags, char **error_r)
                        int ret = BLI_gzip(tempname, dir);
                        
                        if(-1==ret) {
-                               *error_r= "Failed opening .gz file";
+                               BKE_report(reports, RPT_ERROR, "Failed opening .gz file.");
                                return 0;
                        }
                        if(-2==ret) {
-                               *error_r= "Failed opening .blend file for compression";
+                               BKE_report(reports, RPT_ERROR, "Failed opening .blend file for compression.");
                                return 0;
                        }
                }
                else
                if(BLI_rename(tempname, dir) != 0) {
-                       *error_r= "Can't change old file. File saved with @";
+                       BKE_report(reports, RPT_ERROR, "Can't change old file. File saved with @");
                        return 0;
                }
 
                
        } else {
-               *error_r= strerror(errno);
+               BKE_report(reports, RPT_ERROR, strerror(errno));
                remove(tempname);
 
                return 0;
@@ -2165,7 +2166,7 @@ int BLO_write_file(bContext *C, char *dir, int write_flags, char **error_r)
 }
 
 /* return: success (1) */
-int BLO_write_file_mem(bContext *C, MemFile *compare, MemFile *current, int write_flags, char **error_r)
+int BLO_write_file_mem(bContext *C, MemFile *compare, MemFile *current, int write_flags, ReportList *reports)
 {
        int err;
 
@@ -2230,28 +2231,28 @@ static char *get_runtime_path(char *exename) {
 
 #ifdef __APPLE__
 
-static int recursive_copy_runtime(char *outname, char *exename, char **cause_r) 
+static int recursive_copy_runtime(char *outname, char *exename, ReportList *reports)
 {
-       char *cause = NULL, *runtime = get_runtime_path(exename);
+       char *runtime = get_runtime_path(exename);
        char command[2 * (FILE_MAXDIR+FILE_MAXFILE) + 32];
        int progfd = -1;
 
        if (!runtime) {
-               cause= "Unable to find runtime";
+               BKE_report(reports, RPT_ERROR, "Unable to find runtime");
                goto cleanup;
        }
        //printf("runtimepath %s\n", runtime);
                
        progfd= open(runtime, O_BINARY|O_RDONLY, 0);
        if (progfd==-1) {
-               cause= "Unable to find runtime";
+               BKE_report(reports, RPT_ERROR, "Unable to find runtime");
                goto cleanup;
        }
 
        sprintf(command, "/bin/cp -R \"%s\" \"%s\"", runtime, outname);
        //printf("command %s\n", command);
        if (system(command) == -1) {
-               cause = "Couldn't copy runtime";
+               BKE_report(reports, RPT_ERROR, "Couldn't copy runtime");
        }
 
 cleanup:
@@ -2260,24 +2261,19 @@ cleanup:
        if (runtime)
                MEM_freeN(runtime);
 
-       if (cause) {
-               *cause_r= cause;
-               return 0;
-       } else
-               return 1;
+       return !(reports->flag & RPT_HAS_ERROR);
 }
 
-void BLO_write_runtime(bContext *C, char *file, char *exename
+int BLO_write_runtime(bContext *C, char *file, char *exename, ReportList *reports
 {
        char gamename[FILE_MAXDIR+FILE_MAXFILE];
        int outfd = -1;
-       char *cause= NULL;
 
        // remove existing file / bundle
        //printf("Delete file %s\n", file);
        BLI_delete(file, 0, TRUE);
 
-       if (!recursive_copy_runtime(file, exename, &cause))
+       if (!recursive_copy_runtime(file, exename, reports))
                goto cleanup;
 
        strcpy(gamename, file);
@@ -2289,43 +2285,43 @@ void BLO_write_runtime(bContext *C, char *file, char *exename)
                write_file_handle(C, outfd, NULL,NULL, 0, G.fileflags);
 
                if (write(outfd, " ", 1) != 1) {
-                       cause= "Unable to write to output file";
+                       BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
                        goto cleanup;
                }
        } else {
-               cause = "Unable to open blenderfile";
+               BKE_report(reports, RPT_ERROR, "Unable to open blenderfile.");
        }
 
 cleanup:
        if (outfd!=-1)
                close(outfd);
 
-       if (cause)
-               error("Unable to make runtime: %s", cause);
+       //XXX error("Unable to make runtime: %s", cause);
+       return !(reports->flag & RPT_HAS_ERROR);
 }
 
 #else /* !__APPLE__ */
 
-static int handle_append_runtime(int handle, char *exename, char **cause_r) 
+static int handle_append_runtime(int handle, char *exename, ReportList *reports)
 {
-       char *cause= NULL, *runtime= get_runtime_path(exename);
+       char *runtime= get_runtime_path(exename);
        unsigned char buf[1024];
        int count, progfd= -1;
 
        if (!BLI_exists(runtime)) {
-               cause= "Unable to find runtime";
+               BKE_report(reports, RPT_ERROR, "Unable to find runtime.");
                goto cleanup;
        }
 
        progfd= open(runtime, O_BINARY|O_RDONLY, 0);
        if (progfd==-1) {
-               cause= "Unable to find runtime";
+               BKE_report(reports, RPT_ERROR, "Unable to find runtime.@");
                goto cleanup;
        }
 
        while ((count= read(progfd, buf, sizeof(buf)))>0) {
                if (write(handle, buf, count)!=count) {
-                       cause= "Unable to write to output file";
+                       BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
                        goto cleanup;
                }
        }
@@ -2336,11 +2332,7 @@ cleanup:
        if (runtime)
                MEM_freeN(runtime);
 
-       if (cause) {
-               *cause_r= cause;
-               return 0;
-       } else
-               return 1;
+       return !(reports->flag & RPT_HAS_ERROR);
 }
 
 static int handle_write_msb_int(int handle, int i) 
@@ -2354,17 +2346,16 @@ static int handle_write_msb_int(int handle, int i)
        return (write(handle, buf, 4)==4);
 }
 
-void BLO_write_runtime(bContext *C, char *file, char *exename) 
+int BLO_write_runtime(bContext *C, char *file, char *exename, ReportList *reports)
 {
        int outfd= open(file, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0777);
-       char *cause= NULL;
        int datastart;
 
        if (!outfd) {
-               cause= "Unable to open output file";
+               BKE_report(reports, RPT_ERROR, "Unable to open output file.");
                goto cleanup;
        }
-       if (!handle_append_runtime(outfd, exename, &cause))
+       if (!handle_append_runtime(outfd, exename, reports))
                goto cleanup;
 
        datastart= lseek(outfd, 0, SEEK_CUR);
@@ -2372,7 +2363,7 @@ void BLO_write_runtime(bContext *C, char *file, char *exename)
        write_file_handle(C, outfd, NULL,NULL, 0, G.fileflags);
 
        if (!handle_write_msb_int(outfd, datastart) || (write(outfd, "BRUNTIME", 8)!=8)) {
-               cause= "Unable to write to output file";
+               BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
                goto cleanup;
        }
 
@@ -2380,8 +2371,8 @@ cleanup:
        if (outfd!=-1)
                close(outfd);
 
-       if (cause)
-               ; //XXX error("Unable to make runtime: %s", cause);
+       //XXX error("Unable to make runtime: %s", cause);
+       return !(reports->flag & RPT_HAS_ERROR);
 }
 
 #endif /* !__APPLE__ */
index 270cb10730983a8053d3454c3fce0da29a287749..43ab895b398ccda67434de0ee87a7f70985208b7 100644 (file)
@@ -31,6 +31,9 @@
 #ifndef DNA_FILEGLOBAL_TYPES_H
 #define DNA_FILEGLOBAL_TYPES_H
 
+struct bScreen;
+struct Scene;
+
 /**
  * FileGlobal stores a part of the current user-unterface settings at
  * the moment of saving, and the file-specific settings.
@@ -40,8 +43,8 @@ typedef struct FileGlobal {
        short subversion, pads;
        short minversion, minsubversion;
        short displaymode, winpos;
-       void *curscreen;
-       void *curscene;
+       struct bScreen *curscreen;
+       struct Scene *curscene;
        int fileflags;
        int globalf;
 } FileGlobal;
index 01de3c77f015a813555e5f10b441c016eec454bc..8d85956054f9ee6eca3b1affa7b7a160e444ef89 100644 (file)
 extern "C" {
 #endif
 
+struct ReportList;
+
        BlendFileData *
 BLO_readblenfilename(
        char *fileName, 
-       BlendReadError *error_r);
+       struct ReportList *reports);
 
        BlendFileData *
 BLO_readblenfilehandle(
        int fileHandle, 
-       BlendReadError *error_r);
+       struct ReportList *reports);
 
        BlendFileData *
 BLO_readblenfilememory(
        char *fromBuffer,
        int fromBufferSize, 
-       BlendReadError *error_r);
+       struct ReportList *reports);
 
 
        void
@@ -68,7 +70,7 @@ blo_is_a_runtime(
        BlendFileData *
 blo_read_runtime(
        char *file, 
-       BlendReadError *error_r);
+       struct ReportList *reports);
 
 #define BLO_RESERVEDSIZE 12
 extern char *headerMagic;
index ec71611b31d2aeadc0886c1996ae94663b4f5dad..a988b269725cf801248a8a9ffdca1383bd871574 100644 (file)
@@ -51,6 +51,7 @@
 #include "BLO_readblenfile.h"
 
 #include "BKE_blender.h"
+#include "BKE_report.h"
 
 #include "BLI_blenlib.h"
 
@@ -130,7 +131,7 @@ cleanup:
 BlendFileData *
 blo_read_runtime(
        char *path, 
-       BlendReadError *error_r) 
+       ReportList *reports)
 {
        BlendFileData *bfd= NULL;
        int fd, actualsize, datastart;
@@ -138,7 +139,7 @@ blo_read_runtime(
 
        fd= open(path, O_BINARY|O_RDONLY, 0);
        if (fd==-1) {
-               *error_r= BRE_UNABLE_TO_OPEN;
+               BKE_report(reports, RPT_ERROR, "Unable to open");
                goto cleanup;
        }
        
@@ -148,18 +149,18 @@ blo_read_runtime(
 
        datastart= handle_read_msb_int(fd);
        if (datastart==-1) {
-               *error_r= BRE_UNABLE_TO_READ;
+               BKE_report(reports, RPT_ERROR, "Unable to read");
                goto cleanup;
        } else if (read(fd, buf, 8)!=8) {
-               *error_r= BRE_UNABLE_TO_READ;
+               BKE_report(reports, RPT_ERROR, "Unable to read");
                goto cleanup;
        } else if (memcmp(buf, "BRUNTIME", 8)!=0) {
-               *error_r= BRE_NOT_A_BLEND;
+               BKE_report(reports, RPT_ERROR, "File is not a Blender file");
                goto cleanup;
        } else {        
                //printf("starting to read runtime from %s at datastart %d\n", path, datastart);
                lseek(fd, datastart, SEEK_SET);
-               bfd = blo_read_blendafterruntime(fd, path, actualsize-datastart, error_r);
+               bfd = blo_read_blendafterruntime(fd, path, actualsize-datastart, reports);
                fd= -1; // file was closed in blo_read_blendafterruntime()
        }
        
index b6d8ea59a48e5157ad3c82a40db96365a01b6cbe..e26380ce220f517b176f3a9a369b78cad56d683b 100644 (file)
@@ -65,6 +65,7 @@
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_packedFile.h"
+#include "BKE_report.h"
 #include "BKE_texture.h"
 #include "BKE_utildefines.h"
 
@@ -797,7 +798,7 @@ void WM_write_file(bContext *C, char *target)
        Library *li;
        int writeflags, len;
        char di[FILE_MAX];
-       char *err;
+       ReportList reports;
        
        len = strlen(target);
        
@@ -843,8 +844,10 @@ void WM_write_file(bContext *C, char *target)
        writeflags= G.fileflags & ~G_FILE_COMPRESS;
        if(U.flag & USER_FILECOMPRESS)
                writeflags |= G_FILE_COMPRESS;
+
+       BKE_reports_init(&reports, RPT_STORE);
        
-       if (BLO_write_file(C, di, writeflags, &err)) {
+       if (BLO_write_file(C, di, writeflags, &reports)) {
                strcpy(G.sce, di);
                G.relbase_valid = 1;
                strcpy(G.main->name, di);       /* is guaranteed current file */
@@ -858,34 +861,45 @@ void WM_write_file(bContext *C, char *target)
 // XXX         error("%s", err);
        }
 
+       BKE_reports_clear(&reports);
+
 // XXX waitcursor(0);
 }
 
 /* operator entry */
 int WM_write_homefile(bContext *C, wmOperator *op)
 {
-       char *err, tstr[FILE_MAXDIR+FILE_MAXFILE];
+       ReportList reports;
+       char tstr[FILE_MAXDIR+FILE_MAXFILE];
        int write_flags;
        
        BLI_make_file_string("/", tstr, BLI_gethome(), ".B.blend");
                
        /*  force save as regular blend file */
        write_flags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN);
-       BLO_write_file(C, tstr, write_flags, &err);
+
+       // XXX error reporting to the user
+       BKE_reports_init(&reports, RPT_PRINT);
+       BLO_write_file(C, tstr, write_flags, &reports);
+       BKE_reports_clear(&reports);
        
        return OPERATOR_FINISHED;
 }
 
 void WM_write_autosave(bContext *C)
 {
-       char *err, tstr[FILE_MAXDIR+FILE_MAXFILE];
+       ReportList reports;
+       char tstr[FILE_MAXDIR+FILE_MAXFILE];
        int write_flags;
        
        get_autosave_location(tstr);
 
                /*  force save as regular blend file */
        write_flags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN);
-       BLO_write_file(C, tstr, write_flags, &err);
+
+       BKE_reports_init(&reports, RPT_PRINT);
+       BLO_write_file(C, tstr, write_flags, &reports);
+       BKE_reports_clear(&reports);
 }
 
 /* if global undo; remove tempsave, otherwise rename */
index 0dab583567df196cbeb40258e159d4ab96f65b54..6c2e110db76eca73b09df9a7b50f1977ead47c5d 100644 (file)
@@ -70,6 +70,7 @@
 #include "DNA_view3d_types.h"
 #include "DNA_screen_types.h"
 #include "BKE_global.h"
+#include "BKE_report.h"
 #include "BKE_utildefines.h"
 //XXX #include "BIF_screen.h"
 //XXX #include "BIF_scrarea.h"
@@ -91,12 +92,21 @@ void update_for_newframe();
 }
 #endif
 
-static BlendFileData *load_game_data(char *filename) {
-       BlendReadError error;
-       BlendFileData *bfd= BLO_read_from_file(filename, &error);
+static BlendFileData *load_game_data(char *filename)
+{
+       ReportList reports;
+       BlendFileData *bfd;
+       
+       BKE_reports_init(&reports, RPT_STORE);
+       bfd= BLO_read_from_file(filename, &reports);
+
        if (!bfd) {
-               printf("Loading %s failed: %s\n", filename, BLO_bre_as_string(error));
+               printf("Loading %s failed: ", filename);
+               BKE_reports_print(&reports, RPT_ERROR);
        }
+
+       BKE_reports_clear(&reports);
+
        return bfd;
 }
 
index 868dddb901c640ffdbb501904d168aa8efd6246d..bb84b5939e1ddae6e6e028d5b57aa31d6c470781 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "BKE_blender.h"  // initglobals()
 #include "BKE_global.h"  // Global G
+#include "BKE_report.h"
 #include "DNA_scene_types.h"
 #include "DNA_camera_types.h"  // Camera
 #include "DNA_object_types.h"  // Object
@@ -135,15 +136,19 @@ GPC_Engine::~GPC_Engine()
 
 bool GPC_Engine::Start(char *filename)
 {
-       BlendReadError error;
-       BlendFileData *bfd= BLO_read_from_file(filename, &error);
+       ReportList reports;
+       BlendFileData *bfd;
+       
+       BKE_reports_init(&reports, RPT_STORE);
+       bfd= BLO_read_from_file(filename, &reports);
+       BKE_reports_clear(&reports);
 
        if (!bfd) {
                        // XXX, deal with error here
                cout << "Unable to load: " << filename << endl;
                return false;
        }
-       
+
        StartKetsji();
 
        if(bfd->type == BLENFILETYPE_PUB)
@@ -156,8 +161,12 @@ bool GPC_Engine::Start(char *filename)
 bool GPC_Engine::Start(unsigned char *blenderDataBuffer,
                unsigned int blenderDataBufferSize)
 {
-       BlendReadError error;
-       BlendFileData *bfd= BLO_read_from_memory(blenderDataBuffer, blenderDataBufferSize, &error);
+       ReportList reports;
+       BlendFileData *bfd;
+       
+       BKE_reports_init(&reports, RPT_STORE);
+       bfd= BLO_read_from_memory(blenderDataBuffer, blenderDataBufferSize, &reports);
+       BKE_reports_clear(&reports);
 
        if (!bfd) {
                        // XXX, deal with error here
index 0bf0317d8f2ce112478f46558714751c01efc089..8293cfeb36d05c1fea85ae9c58485ba4a5f3b0a1 100644 (file)
@@ -58,6 +58,7 @@ extern "C"
 #include "BKE_global.h"        
 #include "BKE_icons.h" 
 #include "BKE_node.h"  
+#include "BKE_report.h"        
 #include "BLI_blenlib.h"
 #include "DNA_scene_types.h"
 #include "BLO_readfile.h"
@@ -251,35 +252,33 @@ static void get_filename(int argc, char **argv, char *filename)
 #endif // !_APPLE
 }
 
-static BlendFileData *load_game_data(char *progname, char *filename = NULL, char *relativename = NULL) {
-       BlendReadError error;
+static BlendFileData *load_game_data(char *progname, char *filename = NULL, char *relativename = NULL)
+{
+       ReportList reports;
        BlendFileData *bfd = NULL;
+
+       BKE_reports_init(&reports, RPT_STORE);
        
        /* try to load ourself, will only work if we are a runtime */
        if (blo_is_a_runtime(progname)) {
-               bfd= blo_read_runtime(progname, &error);
+               bfd= blo_read_runtime(progname, &reports);
                if (bfd) {
                        bfd->type= BLENFILETYPE_RUNTIME;
                        strcpy(bfd->main->name, progname);
                }
        } else {
-               bfd= BLO_read_from_file(progname, &error);
-       }
-       
-       /*
-       if (bfd && bfd->type == BLENFILETYPE_BLEND) {
-               BLO_blendfiledata_free(bfd);
-               bfd = NULL;
-               error = BRE_NOT_A_PUBFILE;
+               bfd= BLO_read_from_file(progname, &reports);
        }
-       */
        
        if (!bfd && filename) {
                bfd = load_game_data(filename);
                if (!bfd) {
-                       printf("Loading %s failed: %s\n", filename, BLO_bre_as_string(error));
+                       printf("Loading %s failed: ", filename);
+                       BKE_reports_print(&reports, RPT_ERROR);
                }
        }
+
+       BKE_reports_clear(&reports);
        
        return bfd;
 }