2.5: Error reporting
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 29 Dec 2008 13:38:08 +0000 (13:38 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 29 Dec 2008 13:38:08 +0000 (13:38 +0000)
* Added a report list to operator, to which they can report errors and
  warnings. When the operator ends, it will display them with a popup. For
  python these should become exceptions when calling operators.
* Added a function to make a popup menu from a report list.
* Also added a utility function to prepend a string before the reports to
  indicate what they relates to. Also made the report functions used
  BLI_dynstr to simplify the code.
* Made file reading and writing report errors to the user again using this
  system, also replacing the left over uncommented bad level error() calls.

23 files changed:
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/BKE_report.h
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/context.c
source/blender/blenkernel/intern/report.c
source/blender/blenlib/BLI_dynstr.h
source/blender/blenlib/intern/BLI_dynstr.c
source/blender/blenloader/BLO_readfile.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/editors/include/UI_interface.h
source/blender/editors/interface/interface_regions.c
source/blender/editors/space_file/filelist.c
source/blender/makesdna/DNA_space_types.h
source/blender/makesdna/DNA_windowmanager_types.h
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_operators.c
source/creator/creator.c

index 5eb3de4404ed970c0b11ab8b58db3ff9f758c5ea..dbdb570b2f83d902d6dfb763c4f6b71cc0d9ceba 100644 (file)
@@ -40,6 +40,7 @@ extern "C" {
 struct ListBase;
 struct MemFile;
 struct bContext;
 struct ListBase;
 struct MemFile;
 struct bContext;
+struct ReportList;
 
 #define BLENDER_VERSION                        250
 #define BLENDER_SUBVERSION             0
 
 #define BLENDER_VERSION                        250
 #define BLENDER_SUBVERSION             0
@@ -47,9 +48,9 @@ struct bContext;
 #define BLENDER_MINVERSION             250
 #define BLENDER_MINSUBVERSION  0
 
 #define BLENDER_MINVERSION             250
 #define BLENDER_MINSUBVERSION  0
 
-int    BKE_read_file(struct bContext *C, char *dir, void *type_r);
-int BKE_read_file_from_memory(struct bContext *C, char* filebuf, int filelength, void *type_r);
-int BKE_read_file_from_memfile(struct bContext *C, struct MemFile *memfile);
+int BKE_read_file(struct bContext *C, char *dir, void *type_r, struct ReportList *reports);
+int BKE_read_file_from_memory(struct bContext *C, char* filebuf, int filelength, void *type_r, struct ReportList *reports);
+int BKE_read_file_from_memfile(struct bContext *C, struct MemFile *memfile, struct ReportList *reports);
 
 void free_blender(void);
 void initglobals(void);
 
 void free_blender(void);
 void initglobals(void);
index f87910d78721289f7274cec974a005e2c6b61170..8a5c623a225e8c8388d3c2c4adc6bd717461fc94 100644 (file)
@@ -49,7 +49,6 @@ typedef enum ReportType {
 enum ReportListFlags {
        RPT_PRINT = 1,
        RPT_STORE = 2,
 enum ReportListFlags {
        RPT_PRINT = 1,
        RPT_STORE = 2,
-       RPT_HAS_ERROR = 4
 };
 
 typedef struct Report {
 };
 
 typedef struct Report {
@@ -72,6 +71,9 @@ 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, ...);
 
 void BKE_report(ReportList *reports, ReportType type, const char *message);
 void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...);
 
+void BKE_reports_prepend(ReportList *reports, const char *prepend);
+void BKE_reports_prependf(ReportList *reports, const char *prepend, ...);
+
 ReportType BKE_report_print_level(ReportList *reports);
 void BKE_report_print_level_set(ReportList *reports, ReportType level);
 
 ReportType BKE_report_print_level(ReportList *reports);
 void BKE_report_print_level_set(ReportList *reports, ReportType level);
 
index 7c2d4502e5ed1568add49de21004809225d457cd..1ae61bad8b2ad13aa7081e50c18350bf0e6099d4 100644 (file)
@@ -424,15 +424,12 @@ static void handle_subversion_warning(Main *main)
    2: OK, and with new user settings
 */
 
    2: OK, and with new user settings
 */
 
-int BKE_read_file(bContext *C, char *dir, void *unused) 
+int BKE_read_file(bContext *C, char *dir, void *unused, ReportList *reports
 {
 {
-       ReportList reports;
        BlendFileData *bfd;
        int retval= 1;
        BlendFileData *bfd;
        int retval= 1;
-       
-       BKE_reports_init(&reports, RPT_STORE);
 
 
-       bfd= BLO_read_from_file(dir, &reports);
+       bfd= BLO_read_from_file(dir, reports);
        if (bfd) {
                if(bfd->user) retval= 2;
                
        if (bfd) {
                if(bfd->user) retval= 2;
                
@@ -440,50 +437,35 @@ int BKE_read_file(bContext *C, char *dir, void *unused)
                
                handle_subversion_warning(G.main);
        } 
                
                handle_subversion_warning(G.main);
        } 
-       else {
-// XXX         error("Loading %s failed: %s", dir, BLO_bre_as_string(bre));
-       }
-
-       BKE_reports_clear(&reports);
+       else
+               BKE_reports_prependf(reports, "Loading %s failed: ", dir);
                
        return (bfd?retval:0);
 }
 
                
        return (bfd?retval:0);
 }
 
-int BKE_read_file_from_memory(bContext *C, char* filebuf, int filelength, void *unused)
+int BKE_read_file_from_memory(bContext *C, char* filebuf, int filelength, void *unused, ReportList *reports)
 {
 {
-       ReportList reports;
        BlendFileData *bfd;
 
        BlendFileData *bfd;
 
-       BKE_reports_init(&reports, RPT_STORE);
-
-       bfd= BLO_read_from_memory(filebuf, filelength, &reports);
-       if (bfd) {
+       bfd= BLO_read_from_memory(filebuf, filelength, reports);
+       if (bfd)
                setup_app_data(C, bfd, "<memory2>");
                setup_app_data(C, bfd, "<memory2>");
-       } else {
-// XXX         error("Loading failed: %s", BLO_bre_as_string(bre));
-       }
-               
-       BKE_reports_clear(&reports);
+       else
+               BKE_reports_prepend(reports, "Loading failed: ");
 
        return (bfd?1:0);
 }
 
 /* memfile is the undo buffer */
 
        return (bfd?1:0);
 }
 
 /* memfile is the undo buffer */
-int BKE_read_file_from_memfile(bContext *C, MemFile *memfile)
+int BKE_read_file_from_memfile(bContext *C, MemFile *memfile, ReportList *reports)
 {
 {
-       ReportList reports;
        BlendFileData *bfd;
        BlendFileData *bfd;
-       
-       BKE_reports_init(&reports, RPT_STORE);
 
 
-       bfd= BLO_read_from_memfile(CTX_data_main(C), G.sce, memfile, &reports);
-       if (bfd) {
+       bfd= BLO_read_from_memfile(CTX_data_main(C), G.sce, memfile, reports);
+       if (bfd)
                setup_app_data(C, bfd, "<memory1>");
                setup_app_data(C, bfd, "<memory1>");
-       } else {
-// XXX         error("Loading failed: %s", BLO_bre_as_string(bre));
-       }
-               
-       BKE_reports_clear(&reports);
+       else
+               BKE_reports_prepend(reports, "Loading failed: ");
 
        return (bfd?1:0);
 }
 
        return (bfd?1:0);
 }
@@ -516,10 +498,10 @@ static int read_undosave(bContext *C, UndoElem *uel)
        G.fileflags |= G_FILE_NO_UI;
 
        if(UNDO_DISK) 
        G.fileflags |= G_FILE_NO_UI;
 
        if(UNDO_DISK) 
-               success= BKE_read_file(C, uel->str, NULL);
+               success= BKE_read_file(C, uel->str, NULL, NULL);
        else
        else
-               success= BKE_read_file_from_memfile(C, &uel->memfile);
-       
+               success= BKE_read_file_from_memfile(C, &uel->memfile, NULL);
+
        /* restore */
        strcpy(G.sce, scestr);
        G.fileflags= fileflags;
        /* restore */
        strcpy(G.sce, scestr);
        G.fileflags= fileflags;
@@ -571,7 +553,6 @@ void BKE_write_undo(bContext *C, char *name)
 
        /* disk save version */
        if(UNDO_DISK) {
 
        /* disk save version */
        if(UNDO_DISK) {
-               ReportList reports;
                static int counter= 0;
                char tstr[FILE_MAXDIR+FILE_MAXFILE];
                char numstr[32];
                static int counter= 0;
                char tstr[FILE_MAXDIR+FILE_MAXFILE];
                char numstr[32];
@@ -583,22 +564,17 @@ void BKE_write_undo(bContext *C, char *name)
                sprintf(numstr, "%d.blend", counter);
                BLI_make_file_string("/", tstr, btempdir, numstr);
        
                sprintf(numstr, "%d.blend", counter);
                BLI_make_file_string("/", tstr, btempdir, numstr);
        
-               BKE_reports_init(&reports, 0);
-               success= BLO_write_file(CTX_data_main(C), tstr, G.fileflags, &reports);
-               BKE_reports_clear(&reports);
+               success= BLO_write_file(CTX_data_main(C), tstr, G.fileflags, NULL);
                
                strcpy(curundo->str, tstr);
        }
        else {
                
                strcpy(curundo->str, tstr);
        }
        else {
-               ReportList reports;
                MemFile *prevfile=NULL;
                
                if(curundo->prev) prevfile= &(curundo->prev->memfile);
                
                memused= MEM_get_memory_in_use();
                MemFile *prevfile=NULL;
                
                if(curundo->prev) prevfile= &(curundo->prev->memfile);
                
                memused= MEM_get_memory_in_use();
-               BKE_reports_init(&reports, 0);
-               success= BLO_write_file_mem(CTX_data_main(C), prevfile, &curundo->memfile, G.fileflags, &reports);
-               BKE_reports_clear(&reports);
+               success= BLO_write_file_mem(CTX_data_main(C), prevfile, &curundo->memfile, G.fileflags, NULL);
                curundo->undosize= MEM_get_memory_in_use() - memused;
        }
 
                curundo->undosize= MEM_get_memory_in_use() - memused;
        }
 
index fa5740f74e9d8a714fd68871a8085f498e1abd1c..aec497537cf6fc532f2f51f32707fcefc3d71838 100644 (file)
@@ -60,9 +60,6 @@ struct bContext {
                struct ARegion *region;
                struct uiBlock *block;
 
                struct ARegion *region;
                struct uiBlock *block;
 
-               bContextDataCallback screen_cb;
-               bContextDataCallback area_cb;
-               bContextDataCallback region_cb;
                bContextDataCallback block_cb;
        } wm;
        
                bContextDataCallback block_cb;
        } wm;
        
@@ -191,26 +188,22 @@ void CTX_wm_window_set(bContext *C, wmWindow *win)
        C->wm.window= win;
        C->wm.screen= (win)? win->screen: NULL;
        C->data.scene= (C->wm.screen)? C->wm.screen->scene: NULL;
        C->wm.window= win;
        C->wm.screen= (win)? win->screen: NULL;
        C->data.scene= (C->wm.screen)? C->wm.screen->scene: NULL;
-       C->wm.screen_cb= (C->wm.screen)? C->wm.screen->context: NULL;
 }
 
 void CTX_wm_screen_set(bContext *C, bScreen *screen)
 {
        C->wm.screen= screen;
        C->data.scene= (C->wm.screen)? C->wm.screen->scene: NULL;
 }
 
 void CTX_wm_screen_set(bContext *C, bScreen *screen)
 {
        C->wm.screen= screen;
        C->data.scene= (C->wm.screen)? C->wm.screen->scene: NULL;
-       C->wm.screen_cb= (C->wm.screen)? C->wm.screen->context: NULL;
 }
 
 void CTX_wm_area_set(bContext *C, ScrArea *area)
 {
        C->wm.area= area;
 }
 
 void CTX_wm_area_set(bContext *C, ScrArea *area)
 {
        C->wm.area= area;
-       C->wm.area_cb= (area && area->type)? area->type->context: NULL;
 }
 
 void CTX_wm_region_set(bContext *C, ARegion *region)
 {
        C->wm.region= region;
 }
 
 void CTX_wm_region_set(bContext *C, ARegion *region)
 {
        C->wm.region= region;
-       C->wm.region_cb= (region && region->type)? region->type->context: NULL;
 }
 
 void CTX_wm_ui_block_set(bContext *C, struct uiBlock *block, bContextDataCallback cb)
 }
 
 void CTX_wm_ui_block_set(bContext *C, struct uiBlock *block, bContextDataCallback cb)
@@ -240,21 +233,25 @@ static int ctx_data_get(bContext *C, const bContextDataMember *member, bContextD
 
        /* we check recursion to ensure that we do not get infinite
         * loops requesting data from ourselfs in a context callback */
 
        /* we check recursion to ensure that we do not get infinite
         * loops requesting data from ourselfs in a context callback */
-       if(!done && recursion < 1 && C->wm.block_cb) {
+       if(!done && recursion < 1 && C->wm.block) {
                C->data.recursion= 1;
                done= C->wm.block_cb(C, member, result);
        }
                C->data.recursion= 1;
                done= C->wm.block_cb(C, member, result);
        }
-       if(!done && recursion < 2 && C->wm.region_cb) {
+       if(!done && recursion < 2 && C->wm.region) {
                C->data.recursion= 2;
                C->data.recursion= 2;
-               done= C->wm.region_cb(C, member, result);
+               if(C->wm.region->type->context)
+                       done= C->wm.region->type->context(C, member, result);
        }
        }
-       if(!done && recursion < 3 && C->wm.area_cb) {
+       if(!done && recursion < 3 && C->wm.area) {
                C->data.recursion= 3;
                C->data.recursion= 3;
-               done= C->wm.area_cb(C, member, result);
+               if(C->wm.area->type->context)
+                       done= C->wm.area->type->context(C, member, result);
        }
        }
-       if(!done && recursion < 4 && C->wm.screen_cb) {
+       if(!done && recursion < 4 && C->wm.screen) {
+               bContextDataCallback cb= C->wm.screen->context;
                C->data.recursion= 4;
                C->data.recursion= 4;
-               done= C->wm.screen_cb(C, member, result);
+               if(cb)
+                       done= cb(C, member, result);
        }
 
        C->data.recursion= recursion;
        }
 
        C->data.recursion= recursion;
index 12fbaf806d5bd0add83b07d2ef60eef1ad5ed4e4..97bbaf66b3ab4ff21eeb1a294c400ccb1fc65157 100644 (file)
@@ -30,6 +30,7 @@
 #include "DNA_listBase.h"
 
 #include "BLI_blenlib.h"
 #include "DNA_listBase.h"
 
 #include "BLI_blenlib.h"
+#include "BLI_dynstr.h"
 
 #include "BKE_report.h"
 
 
 #include "BKE_report.h"
 
@@ -59,6 +60,9 @@ static char *report_type_str(int type)
 
 void BKE_reports_init(ReportList *reports, int flag)
 {
 
 void BKE_reports_init(ReportList *reports, int flag)
 {
+       if(!reports)
+               return;
+
        memset(reports, 0, sizeof(ReportList));
 
        reports->storelevel= RPT_WARNING;
        memset(reports, 0, sizeof(ReportList));
 
        reports->storelevel= RPT_WARNING;
@@ -70,6 +74,9 @@ void BKE_reports_clear(ReportList *reports)
 {
        Report *report;
 
 {
        Report *report;
 
+       if(!reports)
+               return;
+
        for(report=reports->list.first; report; report=report->next)
                MEM_freeN(report->message);
 
        for(report=reports->list.first; report; report=report->next)
                MEM_freeN(report->message);
 
@@ -81,18 +88,12 @@ void BKE_report(ReportList *reports, ReportType type, const char *message)
        Report *report;
        int len;
 
        Report *report;
        int len;
 
-       if(!reports)
-               return;
-       
-       if(type >= RPT_ERROR)
-               reports->flag |= RPT_HAS_ERROR;
-
-       if((reports->flag & RPT_PRINT) && (type >= reports->printlevel)) {
+       if(!reports || ((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 */
        }
 
                printf("%s: %s\n", report_type_str(type), message);
                fflush(stdout); /* this ensures the message is printed before a crash */
        }
 
-       if((reports->flag & RPT_STORE) && (type >= reports->storelevel)) {
+       if(reports && (reports->flag & RPT_STORE) && (type >= reports->storelevel)) {
                report= MEM_callocN(sizeof(Report), "Report");
                report->type= type;
                report->typestr= report_type_str(type);
                report= MEM_callocN(sizeof(Report), "Report");
                report->type= type;
                report->typestr= report_type_str(type);
@@ -107,83 +108,110 @@ void BKE_report(ReportList *reports, ReportType type, const char *message)
 
 void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...)
 {
 
 void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...)
 {
+       DynStr *ds;
        Report *report;
        va_list args;
        Report *report;
        va_list args;
-       char *message;
-       int len= 256, maxlen= 65536, retval;
-
-       if(!reports)
-               return;
-
-       if(type >= RPT_ERROR)
-               reports->flag |= RPT_HAS_ERROR;
 
 
-       if((reports->flag & RPT_PRINT) && (type >= reports->printlevel)) {
+       if(!reports || ((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 */
        }
 
                va_start(args, format);
                vprintf(format, args);
                va_end(args);
                fflush(stdout); /* this ensures the message is printed before a crash */
        }
 
-       if((reports->flag & RPT_STORE) && (type >= reports->storelevel)) {
-               while(1) {
-                       message= MEM_callocN(sizeof(char)*len+1, "ReportMessage");
-
-                       va_start(args, format);
-                       retval= vsnprintf(message, len, format, args);
-                       va_end(args);
-
-                       if(retval == -1) {
-                               /* -1 means not enough space, but on windows it may also mean
-                                * there is a formatting error, so we impose a maximum length */
-                               MEM_freeN(message);
-                               message= NULL;
-
-                               len *= 2;
-                               if(len > maxlen) {
-                                       fprintf(stderr, "BKE_reportf message too long or format error.\n");
-                                       break;
-                               }
-                       }
-                       else if(retval > len) {
-                               /* in C99 the actual length required is returned */
-                               MEM_freeN(message);
-                               message= NULL;
-
-                               len= retval;
-                       }
-                       else
-                               break;
-               }
-
-               if(message) {
-                       report= MEM_callocN(sizeof(Report), "Report");
-                       report->type= type;
-                       report->typestr= report_type_str(type);
-                       report->message= message;
-
-                       BLI_addtail(&reports->list, report);
-               }
+       if(reports && (reports->flag & RPT_STORE) && (type >= reports->storelevel)) {
+               report= MEM_callocN(sizeof(Report), "Report");
+
+               ds= BLI_dynstr_new();
+               va_start(args, format);
+               BLI_dynstr_vappendf(ds, format, args);
+               va_end(args);
+
+               report->message= BLI_dynstr_get_cstring(ds);
+
+               BLI_dynstr_free(ds);
+
+               report->type= type;
+               report->typestr= report_type_str(type);
+
+               BLI_addtail(&reports->list, report);
+       }
+}
+
+void BKE_reports_prepend(ReportList *reports, const char *prepend)
+{
+       Report *report;
+       DynStr *ds;
+
+       if(!reports)
+               return;
+
+       for(report=reports->list.first; report; report=report->next) {
+               ds= BLI_dynstr_new();
+
+               BLI_dynstr_append(ds, prepend);
+               BLI_dynstr_append(ds, report->message);
+               MEM_freeN(report->message);
+
+               report->message= BLI_dynstr_get_cstring(ds);
+
+               BLI_dynstr_free(ds);
+       }
+}
+
+void BKE_reports_prependf(ReportList *reports, const char *prepend, ...)
+{
+       Report *report;
+       DynStr *ds;
+       va_list args;
+
+       if(!reports)
+               return;
+
+       for(report=reports->list.first; report; report=report->next) {
+               ds= BLI_dynstr_new();
+               va_start(args, prepend);
+               BLI_dynstr_vappendf(ds, prepend, args);
+               va_end(args);
+
+               BLI_dynstr_append(ds, report->message);
+               MEM_freeN(report->message);
+
+               report->message= BLI_dynstr_get_cstring(ds);
+
+               BLI_dynstr_free(ds);
        }
 }
 
 ReportType BKE_report_print_level(ReportList *reports)
 {
        }
 }
 
 ReportType BKE_report_print_level(ReportList *reports)
 {
+       if(!reports)
+               return RPT_ERROR;
+
        return reports->printlevel;
 }
 
 void BKE_report_print_level_set(ReportList *reports, ReportType level)
 {
        return reports->printlevel;
 }
 
 void BKE_report_print_level_set(ReportList *reports, ReportType level)
 {
+       if(!reports)
+               return;
+
        reports->printlevel= level;
 }
 
 ReportType BKE_report_store_level(ReportList *reports)
 {
        reports->printlevel= level;
 }
 
 ReportType BKE_report_store_level(ReportList *reports)
 {
+       if(!reports)
+               return RPT_ERROR;
+
        return reports->storelevel;
 }
 
 void BKE_report_store_level_set(ReportList *reports, ReportType level)
 {
        return reports->storelevel;
 }
 
 void BKE_report_store_level_set(ReportList *reports, ReportType level)
 {
+       if(!reports)
+               return;
+
        reports->storelevel= level;
 }
 
        reports->storelevel= level;
 }
 
index 453e15a0f3b4be5c0d0ac54f047e2993c0c41b4c..39bb4e9e113fba97c8db7130010c7b5bee97b8c8 100644 (file)
@@ -38,6 +38,8 @@
 #ifndef BLI_DYNSTR_H
 #define BLI_DYNSTR_H
 
 #ifndef BLI_DYNSTR_H
 #define BLI_DYNSTR_H
 
+#include <stdarg.h>
+
 struct DynStr;
 
        /** The abstract DynStr type */
 struct DynStr;
 
        /** The abstract DynStr type */
@@ -65,6 +67,7 @@ void  BLI_dynstr_append                               (DynStr *ds, const char *cstr);
         * @param format The printf format string to use.
         */
 void   BLI_dynstr_appendf                              (DynStr *ds, const char *format, ...);
         * @param format The printf format string to use.
         */
 void   BLI_dynstr_appendf                              (DynStr *ds, const char *format, ...);
+void   BLI_dynstr_vappendf                             (DynStr *ds, const char *format, va_list args);
 
        /**
         * Find the length of a DynStr.
 
        /**
         * Find the length of a DynStr.
index 1c539af295720ed7ca2aef6641a3e69cfed283db..04388ea946fda81c58a62d352b3e79bc2e6f23dd 100644 (file)
@@ -83,9 +83,8 @@ void BLI_dynstr_append(DynStr *ds, const char *cstr) {
        ds->curlen+= cstrlen;
 }
 
        ds->curlen+= cstrlen;
 }
 
-void BLI_dynstr_appendf(DynStr *ds, const char *format, ...)
+void BLI_dynstr_vappendf(DynStr *ds, const char *format, va_list args)
 {
 {
-       va_list args;
        char *message, fixedmessage[256];
        int len= 256, maxlen= 65536, retval;
 
        char *message, fixedmessage[256];
        int len= 256, maxlen= 65536, retval;
 
@@ -95,9 +94,7 @@ void BLI_dynstr_appendf(DynStr *ds, const char *format, ...)
                else
                        message= MEM_callocN(sizeof(char)*len+1, "BLI_dynstr_appendf");
 
                else
                        message= MEM_callocN(sizeof(char)*len+1, "BLI_dynstr_appendf");
 
-               va_start(args, format);
                retval= vsnprintf(message, len, format, args);
                retval= vsnprintf(message, len, format, args);
-               va_end(args);
 
                if(retval == -1) {
                        /* -1 means not enough space, but on windows it may also mean
 
                if(retval == -1) {
                        /* -1 means not enough space, but on windows it may also mean
@@ -132,6 +129,15 @@ void BLI_dynstr_appendf(DynStr *ds, const char *format, ...)
        }
 }
 
        }
 }
 
+void BLI_dynstr_appendf(DynStr *ds, const char *format, ...)
+{
+       va_list args;
+
+       va_start(args, format);
+       BLI_dynstr_vappendf(ds, format, args);
+       va_end(args);
+}
+
 int BLI_dynstr_get_len(DynStr *ds) {
        return ds->curlen;
 }
 int BLI_dynstr_get_len(DynStr *ds) {
        return ds->curlen;
 }
index 59289b7e74c94846d63939043f606feba92e94b2..a09c45d0399a25625777c52c937dcfd48a132fab 100644 (file)
@@ -200,10 +200,10 @@ BLO_blendhandle_close(
 char *BLO_gethome(void);
 int BLO_has_bfile_extension(char *str);
 
 char *BLO_gethome(void);
 int BLO_has_bfile_extension(char *str);
 
-void BLO_library_append(struct SpaceFile *sfile, char *dir, int idcode, struct Main *mainvar, struct Scene *scene);
+void BLO_library_append(struct SpaceFile *sfile, char *dir, int idcode, struct Main *mainvar, struct Scene *scene, struct ReportList *reports);
 void BLO_library_append_(BlendHandle **libfiledata, struct direntry* filelist, int totfile, 
 void BLO_library_append_(BlendHandle **libfiledata, struct direntry* filelist, int totfile, 
-                                                char *dir, char* file, short flag, int idcode, struct Main *mainvar, struct Scene *scene);
-void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, int idcode, short flag, struct Main *mainvar, struct Scene *scene);
+                                                char *dir, char* file, short flag, int idcode, struct Main *mainvar, struct Scene *scene, struct ReportList *reports);
+void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, int idcode, short flag, struct Main *mainvar, struct Scene *scene, struct ReportList *reports);
 
 BlendFileData* blo_read_blendafterruntime(int file, char *name, int actualsize, struct ReportList *reports);
 
 
 BlendFileData* blo_read_blendafterruntime(int file, char *name, int actualsize, struct ReportList *reports);
 
index e7e45597887ae8bf6d0027f6b82f8f4f175255cc..23e334fbbd17df1e688169ac191673ca05e42a1c 100644 (file)
@@ -166,12 +166,9 @@ int BLO_idcode_from_name(char *name)
         
 BlendHandle *BLO_blendhandle_from_file(char *file) 
 {
         
 BlendHandle *BLO_blendhandle_from_file(char *file) 
 {
-       ReportList reports;
        BlendHandle *bh;
 
        BlendHandle *bh;
 
-       BKE_reports_init(&reports, 0);
-       bh= (BlendHandle*)blo_openblenderfile(file, &reports);
-       BKE_reports_clear(&reports);
+       bh= (BlendHandle*)blo_openblenderfile(file, NULL);
 
        return bh;
 }
 
        return bh;
 }
@@ -330,7 +327,8 @@ BlendFileData *BLO_read_from_file(char *file, ReportList *reports)
                
        fd = blo_openblenderfile(file, reports);
        if (fd) {
                
        fd = blo_openblenderfile(file, reports);
        if (fd) {
-               bfd= blo_read_file_internal(fd, reports);
+               fd->reports= reports;
+               bfd= blo_read_file_internal(fd);
                if (bfd) {
                        bfd->type= BLENFILETYPE_BLEND;
                        strncpy(bfd->main->name, file, sizeof(bfd->main->name)-1);
                if (bfd) {
                        bfd->type= BLENFILETYPE_BLEND;
                        strncpy(bfd->main->name, file, sizeof(bfd->main->name)-1);
@@ -348,7 +346,8 @@ BlendFileData *BLO_read_from_memory(void *mem, int memsize, ReportList *reports)
                
        fd = blo_openblendermemory(mem, memsize,  reports);
        if (fd) {
                
        fd = blo_openblendermemory(mem, memsize,  reports);
        if (fd) {
-               bfd= blo_read_file_internal(fd, reports);
+               fd->reports= reports;
+               bfd= blo_read_file_internal(fd);
                if (bfd) {
                        bfd->type= BLENFILETYPE_BLEND;
                        strcpy(bfd->main->name, "");
                if (bfd) {
                        bfd->type= BLENFILETYPE_BLEND;
                        strcpy(bfd->main->name, "");
@@ -367,6 +366,7 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, const char *filename, MemFil
        
        fd = blo_openblendermemfile(memfile, reports);
        if (fd) {
        
        fd = blo_openblendermemfile(memfile, reports);
        if (fd) {
+               fd->reports= reports;
                strcpy(fd->filename, filename);
                
                /* clear ob->proxy_from pointers in old main */
                strcpy(fd->filename, filename);
                
                /* clear ob->proxy_from pointers in old main */
@@ -380,7 +380,7 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, const char *filename, MemFil
                /* makes lookup of existing images in old main */
                blo_make_image_pointer_map(fd, oldmain);
                
                /* makes lookup of existing images in old main */
                blo_make_image_pointer_map(fd, oldmain);
                
-               bfd= blo_read_file_internal(fd, reports);
+               bfd= blo_read_file_internal(fd);
                if (bfd) {
                        bfd->type= BLENFILETYPE_BLEND;
                        strcpy(bfd->main->name, "");
                if (bfd) {
                        bfd->type= BLENFILETYPE_BLEND;
                        strcpy(bfd->main->name, "");
index 399ce3d6ef8debcfc683efcc90bc48a4ce76df77..1de3868a1c90e148410c5b677a022bf62e63970a 100644 (file)
 
 #include "readfile.h"
 
 
 #include "readfile.h"
 
-//XXX #include "wm_event_types.h"
-
 #include <errno.h>
 
 /*
 #include <errno.h>
 
 /*
@@ -3111,7 +3109,7 @@ static void lib_link_object(FileData *fd, Main *main)
                ob= ob->id.next;
        }
 
                ob= ob->id.next;
        }
 
-       if(warn) //XXX error("WARNING IN CONSOLE");
+       if(warn)
                BKE_report(fd->reports, RPT_WARNING, "Warning in console");
 }
 
                BKE_report(fd->reports, RPT_WARNING, "Warning in console");
 }
 
@@ -3808,7 +3806,7 @@ static void lib_link_windowmanager(FileData *fd, Main *main)
        }
 }
 
        }
 }
 
-/* ************ READ SCREEN ***************** */
+/* ****************** READ GREASE PENCIL ***************** */
 
 /* relinks grease-pencil data for 3d-view(s) - used for direct_link */
 static void link_gpencil(FileData *fd, bGPdata *gpd)
 
 /* relinks grease-pencil data for 3d-view(s) - used for direct_link */
 static void link_gpencil(FileData *fd, bGPdata *gpd)
@@ -3836,6 +3834,29 @@ static void link_gpencil(FileData *fd, bGPdata *gpd)
        }
 }
 
        }
 }
 
+/* ****************** READ SCREEN ***************** */
+
+static void butspace_version_132(SpaceButs *buts)
+{
+       buts->v2d.tot.xmin= 0.0f;
+       buts->v2d.tot.ymin= 0.0f;
+       buts->v2d.tot.xmax= 1279.0f;
+       buts->v2d.tot.ymax= 228.0f;
+
+       buts->v2d.min[0]= 256.0f;
+       buts->v2d.min[1]= 42.0f;
+
+       buts->v2d.max[0]= 2048.0f;
+       buts->v2d.max[1]= 450.0f;
+
+       buts->v2d.minzoom= 0.5f;
+       buts->v2d.maxzoom= 1.21f;
+
+       buts->v2d.scroll= 0;
+       buts->v2d.keepzoom= 1;
+       buts->v2d.keeptot= 1;
+}
+
 /* note: file read without screens option G_FILE_NO_UI; 
    check lib pointers in call below */
 static void lib_link_screen(FileData *fd, Main *main)
 /* note: file read without screens option G_FILE_NO_UI; 
    check lib pointers in call below */
 static void lib_link_screen(FileData *fd, Main *main)
@@ -3887,7 +3908,8 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                SpaceButs *sbuts= (SpaceButs *)sl;
                                                sbuts->lockpoin= NULL;
                                                sbuts->ri= NULL;
                                                SpaceButs *sbuts= (SpaceButs *)sl;
                                                sbuts->lockpoin= NULL;
                                                sbuts->ri= NULL;
-// XXX                                         if(main->versionfile<132) set_rects_butspace(sbuts);
+                                               if(main->versionfile<132)
+                                                       butspace_version_132(sbuts);
                                        }
                                        else if(sl->spacetype==SPACE_FILE) {
                                                SpaceFile *sfile= (SpaceFile *)sl;
                                        }
                                        else if(sl->spacetype==SPACE_FILE) {
                                                SpaceFile *sfile= (SpaceFile *)sl;
@@ -4189,6 +4211,7 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
        link_list(fd, &(sc->edgebase));
        link_list(fd, &(sc->areabase));
        sc->regionbase.first= sc->regionbase.last= NULL;
        link_list(fd, &(sc->edgebase));
        link_list(fd, &(sc->areabase));
        sc->regionbase.first= sc->regionbase.last= NULL;
+       sc->context= NULL;
 
        sc->mainwin= sc->subwinactive= 0;       /* indices */
        
 
        sc->mainwin= sc->subwinactive= 0;       /* indices */
        
@@ -4340,7 +4363,6 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
                                BLI_remlink(&main->library, lib);
                                MEM_freeN(lib);
                                
                                BLI_remlink(&main->library, lib);
                                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;
                                BKE_report(fd->reports, RPT_WARNING, "Library had multiple instances, save and reload!");
 
                                return;
@@ -5602,8 +5624,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                SpaceLink *sl= sa->spacedata.first;
                                while(sl) {
                                        if(sl->spacetype==SPACE_BUTS) {
                                SpaceLink *sl= sa->spacedata.first;
                                while(sl) {
                                        if(sl->spacetype==SPACE_BUTS) {
-                                               //SpaceButs *sbuts= (SpaceButs*) sl;
-                                               //XXX sbuts->scaflag= BUTS_SENS_LINK|BUTS_SENS_ACT|BUTS_CONT_ACT|BUTS_ACT_ACT|BUTS_ACT_LINK;
+                                               SpaceButs *sbuts= (SpaceButs*) sl;
+                                               sbuts->scaflag= BUTS_SENS_LINK|BUTS_SENS_ACT|BUTS_CONT_ACT|BUTS_ACT_ACT|BUTS_ACT_LINK;
                                        }
                                        sl= sl->next;
                                }
                                        }
                                        sl= sl->next;
                                }
@@ -6254,8 +6276,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                                sbuts->v2d.maxzoom= 1.2f;
                                                sbuts->align= 1;        /* horizontal default */
                                        
                                                sbuts->v2d.maxzoom= 1.2f;
                                                sbuts->align= 1;        /* horizontal default */
                                        
-                                               //XXX
-#if 0
                                                if(sbuts->mainb==BUTS_LAMP) {
                                                        sbuts->mainb= CONTEXT_SHADING;
                                                        sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP;
                                                if(sbuts->mainb==BUTS_LAMP) {
                                                        sbuts->mainb= CONTEXT_SHADING;
                                                        sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP;
@@ -6299,7 +6319,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                                        sbuts->mainb= CONTEXT_EDITING;
                                                }
                                                else sbuts->mainb= CONTEXT_SCENE;
                                                        sbuts->mainb= CONTEXT_EDITING;
                                                }
                                                else sbuts->mainb= CONTEXT_SCENE;
-#endif
                                        }
                                }
                        }
                                        }
                                }
                        }
@@ -8424,7 +8443,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
        return bhead;
 }
 
        return bhead;
 }
 
-BlendFileData *blo_read_file_internal(FileData *fd, ReportList *reports)
+BlendFileData *blo_read_file_internal(FileData *fd)
 {
        BHead *bhead= blo_firstbhead(fd);
        BlendFileData *bfd;
 {
        BHead *bhead= blo_firstbhead(fd);
        BlendFileData *bfd;
@@ -9480,26 +9499,33 @@ static Library* library_append(Main *mainvar, Scene *scene, char* file, char *di
 /* this should probably be moved into the Python code anyway */
 
 void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, 
 /* this should probably be moved into the Python code anyway */
 
 void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, 
-               int idcode, short flag, Main *mainvar, Scene *scene)
+               int idcode, short flag, Main *mainvar, Scene *scene, ReportList *reports)
 {
 {
+       FileData *fd= (FileData*)(*bh);
+
        /* try to append the requested object */
        /* try to append the requested object */
-       library_append(mainvar, scene, name, dir, idcode, 0, (FileData **)bh, NULL, 0, flag );
+       fd->reports= reports;
+       library_append(mainvar, scene, name, dir, idcode, 0, &fd, NULL, 0, flag );
+       if(fd) fd->reports= NULL;
 
        /* do we need to do this? */
        DAG_scene_sort(scene);
 
        /* do we need to do this? */
        DAG_scene_sort(scene);
+
+       *bh= (BlendHandle*)fd;
 }
 
 /* append to scene */
 /* dir is a full path */       
 }
 
 /* append to scene */
 /* dir is a full path */       
-void BLO_library_append(SpaceFile *sfile, char *dir, int idcode, Main *mainvar, Scene *scene)
+void BLO_library_append(SpaceFile *sfile, char *dir, int idcode, Main *mainvar, Scene *scene, ReportList *reports)
 {
        BLO_library_append_(&sfile->libfiledata, sfile->filelist, sfile->totfile, 
 {
        BLO_library_append_(&sfile->libfiledata, sfile->filelist, sfile->totfile, 
-                                               dir, sfile->file, sfile->flag, idcode, mainvar, scene);
+                                               dir, sfile->file, sfile->flag, idcode, mainvar, scene, reports);
 }
 
 }
 
-void BLO_library_append_(BlendHandle** libfiledata, struct direntry* filelist, int totfile, 
-                                                char *dir, char* file, short flag, int idcode, Main *mainvar, Scene *scene)
+void BLO_library_append_(BlendHandle** bh, struct direntry* filelist, int totfile, 
+                                                char *dir, char* file, short flag, int idcode, Main *mainvar, Scene *scene, ReportList *reports)
 {
 {
+       FileData *fd= (FileData*)(*bh);
        Library *curlib;
        Base *centerbase;
        Object *ob;
        Library *curlib;
        Base *centerbase;
        Object *ob;
@@ -9519,12 +9545,12 @@ void BLO_library_append_(BlendHandle** libfiledata, struct direntry* filelist, i
                                if( strcmp(filelist[a].relname, file)==0) break;
                        }
                        if(a==totfile) {
                                if( strcmp(filelist[a].relname, file)==0) break;
                        }
                        if(a==totfile) {
-                               //XXX error("Wrong indicated name");
+                               BKE_report(reports, RPT_ERROR, "Wrong indicated name");
                                return;
                        }
                }
                else {
                                return;
                        }
                }
                else {
-                       //XXX error("Nothing indicated");
+                       BKE_report(reports, RPT_ERROR, "Nothing indicated");
                        return;
                }
        }
                        return;
                }
        }
@@ -9532,7 +9558,11 @@ void BLO_library_append_(BlendHandle** libfiledata, struct direntry* filelist, i
        
        if(flag & FILE_AUTOSELECT) scene_deselect_all(scene);
 
        
        if(flag & FILE_AUTOSELECT) scene_deselect_all(scene);
 
-       curlib = library_append(mainvar, scene, file, dir, idcode, totsel, (FileData**) libfiledata, filelist, totfile,flag );
+       fd->reports= reports;
+       curlib = library_append(mainvar, scene, file, dir, idcode, totsel, &fd, filelist, totfile,flag );
+       if(fd) fd->reports= NULL;
+
+       *bh= (BlendHandle*)fd;
 
        /* when not linking (appending)... */
        if((flag & FILE_LINK)==0) {
 
        /* when not linking (appending)... */
        if((flag & FILE_LINK)==0) {
@@ -9614,9 +9644,8 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
                                        ReportList reports;
 
                                        printf("read library: lib %s\n", mainptr->curlib->name);
                                        ReportList reports;
 
                                        printf("read library: lib %s\n", mainptr->curlib->name);
-                                       BKE_reports_init(&reports, 0);
                                        fd= blo_openblenderfile(mainptr->curlib->filename, &reports);
                                        fd= blo_openblenderfile(mainptr->curlib->filename, &reports);
-                                       BKE_reports_clear(&reports);
+                                       fd->reports= basefd->reports;
 
                                        if (fd) {
                                                if (fd->libmap)
 
                                        if (fd) {
                                                if (fd->libmap)
@@ -9731,7 +9760,8 @@ BlendFileData *blo_read_blendafterruntime(int file, char *name, int actualsize,
        if (!fd)
                return NULL;
 
        if (!fd)
                return NULL;
 
-       bfd= blo_read_file_internal(fd, reports);
+       fd->reports= reports;
+       bfd= blo_read_file_internal(fd);
        blo_freefiledata(fd);
 
        return bfd;
        blo_freefiledata(fd);
 
        return bfd;
index 08797d3608496f81d5244f85f262fa8529360b40..b084e377d19b1feba309ee02e8c6b06c48038f01 100644 (file)
@@ -107,10 +107,10 @@ struct Main;
 void blo_join_main(ListBase *mainlist);
 void blo_split_main(ListBase *mainlist, struct Main *main);
 
 void blo_join_main(ListBase *mainlist);
 void blo_split_main(ListBase *mainlist, struct Main *main);
 
-BlendFileData *blo_read_file_internal( FileData *fd, struct ReportList *reports);
+BlendFileData *blo_read_file_internal(FileData *fd);
 
 
-FileData *blo_openblenderfile( char *name, struct ReportList *reports);
-FileData *blo_openblendermemory( void *buffer, int buffersize, struct ReportList *reports);
+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, Main *oldmain);
 FileData *blo_openblendermemfile(struct MemFile *memfile, struct ReportList *reports);
 
 void blo_clear_proxy_pointers_from_lib(FileData *fd, Main *oldmain);
index 7c7325ab8fa45d94908b935439b6f380fd5d7ba8..1b8db72f4ec540a6d02d563fa26ce096a3199b3c 100644 (file)
@@ -2265,20 +2265,22 @@ cleanup:
        if (runtime)
                MEM_freeN(runtime);
 
        if (runtime)
                MEM_freeN(runtime);
 
-       return !(reports->flag & RPT_HAS_ERROR);
+       return !BKE_reports_have_error(reports);
 }
 
 int BLO_write_runtime(Main *mainvar, char *file, char *exename, ReportList *reports) 
 {
        char gamename[FILE_MAXDIR+FILE_MAXFILE];
 }
 
 int BLO_write_runtime(Main *mainvar, char *file, char *exename, ReportList *reports) 
 {
        char gamename[FILE_MAXDIR+FILE_MAXFILE];
-       int outfd = -1;
+       int outfd = -1, error= 0;
 
        // remove existing file / bundle
        //printf("Delete file %s\n", file);
        BLI_delete(file, 0, TRUE);
 
 
        // remove existing file / bundle
        //printf("Delete file %s\n", file);
        BLI_delete(file, 0, TRUE);
 
-       if (!recursive_copy_runtime(file, exename, reports))
+       if (!recursive_copy_runtime(file, exename, reports)) {
+               error= 1;
                goto cleanup;
                goto cleanup;
+       }
 
        strcpy(gamename, file);
        strcat(gamename, "/Contents/Resources/game.blend");
 
        strcpy(gamename, file);
        strcat(gamename, "/Contents/Resources/game.blend");
@@ -2290,18 +2292,20 @@ int BLO_write_runtime(Main *mainvar, char *file, char *exename, ReportList *repo
 
                if (write(outfd, " ", 1) != 1) {
                        BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
 
                if (write(outfd, " ", 1) != 1) {
                        BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
+                       error= 1;
                        goto cleanup;
                }
        } else {
                BKE_report(reports, RPT_ERROR, "Unable to open blenderfile.");
                        goto cleanup;
                }
        } else {
                BKE_report(reports, RPT_ERROR, "Unable to open blenderfile.");
+               error= 1;
        }
 
 cleanup:
        if (outfd!=-1)
                close(outfd);
 
        }
 
 cleanup:
        if (outfd!=-1)
                close(outfd);
 
-       //XXX error("Unable to make runtime: %s", cause);
-       return !(reports->flag & RPT_HAS_ERROR);
+       BKE_reports_prepend(reports, "Unable to make runtime: ");
+       return !error;
 }
 
 #else /* !__APPLE__ */
 }
 
 #else /* !__APPLE__ */
@@ -2310,22 +2314,25 @@ static int handle_append_runtime(int handle, char *exename, ReportList *reports)
 {
        char *runtime= get_runtime_path(exename);
        unsigned char buf[1024];
 {
        char *runtime= get_runtime_path(exename);
        unsigned char buf[1024];
-       int count, progfd= -1;
+       int count, progfd= -1, error= 0;
 
        if (!BLI_exists(runtime)) {
                BKE_report(reports, RPT_ERROR, "Unable to find runtime.");
 
        if (!BLI_exists(runtime)) {
                BKE_report(reports, RPT_ERROR, "Unable to find runtime.");
+               error= 1;
                goto cleanup;
        }
 
        progfd= open(runtime, O_BINARY|O_RDONLY, 0);
        if (progfd==-1) {
                BKE_report(reports, RPT_ERROR, "Unable to find runtime.@");
                goto cleanup;
        }
 
        progfd= open(runtime, O_BINARY|O_RDONLY, 0);
        if (progfd==-1) {
                BKE_report(reports, RPT_ERROR, "Unable to find runtime.@");
+               error= 1;
                goto cleanup;
        }
 
        while ((count= read(progfd, buf, sizeof(buf)))>0) {
                if (write(handle, buf, count)!=count) {
                        BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
                goto cleanup;
        }
 
        while ((count= read(progfd, buf, sizeof(buf)))>0) {
                if (write(handle, buf, count)!=count) {
                        BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
+                       error= 1;
                        goto cleanup;
                }
        }
                        goto cleanup;
                }
        }
@@ -2336,7 +2343,7 @@ cleanup:
        if (runtime)
                MEM_freeN(runtime);
 
        if (runtime)
                MEM_freeN(runtime);
 
-       return !(reports->flag & RPT_HAS_ERROR);
+       return !error;
 }
 
 static int handle_write_msb_int(int handle, int i) 
 }
 
 static int handle_write_msb_int(int handle, int i) 
@@ -2353,14 +2360,17 @@ static int handle_write_msb_int(int handle, int i)
 int BLO_write_runtime(Main *mainvar, char *file, char *exename, ReportList *reports)
 {
        int outfd= open(file, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0777);
 int BLO_write_runtime(Main *mainvar, char *file, char *exename, ReportList *reports)
 {
        int outfd= open(file, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0777);
-       int datastart;
+       int datastart, error= 0;
 
        if (!outfd) {
                BKE_report(reports, RPT_ERROR, "Unable to open output file.");
 
        if (!outfd) {
                BKE_report(reports, RPT_ERROR, "Unable to open output file.");
+               error= 1;
                goto cleanup;
        }
                goto cleanup;
        }
-       if (!handle_append_runtime(outfd, exename, reports))
+       if (!handle_append_runtime(outfd, exename, reports)) {
+               error= 1;
                goto cleanup;
                goto cleanup;
+       }
 
        datastart= lseek(outfd, 0, SEEK_CUR);
 
 
        datastart= lseek(outfd, 0, SEEK_CUR);
 
@@ -2368,6 +2378,7 @@ int BLO_write_runtime(Main *mainvar, char *file, char *exename, ReportList *repo
 
        if (!handle_write_msb_int(outfd, datastart) || (write(outfd, "BRUNTIME", 8)!=8)) {
                BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
 
        if (!handle_write_msb_int(outfd, datastart) || (write(outfd, "BRUNTIME", 8)!=8)) {
                BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
+               error= 1;
                goto cleanup;
        }
 
                goto cleanup;
        }
 
@@ -2375,8 +2386,8 @@ cleanup:
        if (outfd!=-1)
                close(outfd);
 
        if (outfd!=-1)
                close(outfd);
 
-       //XXX error("Unable to make runtime: %s", cause);
-       return !(reports->flag & RPT_HAS_ERROR);
+       BKE_reports_prepend(reports, "Unable to make runtime: ");
+       return !error;
 }
 
 #endif /* !__APPLE__ */
 }
 
 #endif /* !__APPLE__ */
index 3b0c9beb70bc2805c714d911780bc248292b1e5a..69232d41efebfc217d01124ac187a50178e69567 100644 (file)
@@ -40,6 +40,7 @@ struct AutoComplete;
 struct bContext;
 struct PointerRNA;
 struct PropertyRNA;
 struct bContext;
 struct PointerRNA;
 struct PropertyRNA;
+struct ReportList;
 
 /* uiBlock->dt */
 #define UI_EMBOSS              0       /* use one of the themes for drawing */
 
 /* uiBlock->dt */
 #define UI_EMBOSS              0       /* use one of the themes for drawing */
@@ -216,6 +217,7 @@ void uiPupmenuOkee(struct bContext *C, char *opname, char *str, ...);
 void uiPupmenuSaveOver(struct bContext *C, char *opname, char *filename, ...);
 void uiPupmenuNotice(struct bContext *C, char *str, ...);
 void uiPupmenuError(struct bContext *C, char *str, ...);
 void uiPupmenuSaveOver(struct bContext *C, char *opname, char *filename, ...);
 void uiPupmenuNotice(struct bContext *C, char *str, ...);
 void uiPupmenuError(struct bContext *C, char *str, ...);
+void uiPupmenuReports(struct bContext *C, struct ReportList *reports);
 
 /* Block */
 
 
 /* Block */
 
index 063255bed86eef1934da8f75b120c695ca88fd09..72a0fd811d04aab7f512a9e17c46e5813ef7016b 100644 (file)
 
 #include "BLI_arithb.h"
 #include "BLI_blenlib.h"
 
 #include "BLI_arithb.h"
 #include "BLI_blenlib.h"
+#include "BLI_dynstr.h"
 
 #include "BKE_context.h"
 
 #include "BKE_context.h"
+#include "BKE_report.h"
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
 
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
 
@@ -1765,3 +1767,30 @@ void uiPupmenuError(bContext *C, char *str, ...)
        va_end(ap);
 }
 
        va_end(ap);
 }
 
+void uiPupmenuReports(bContext *C, ReportList *reports)
+{
+       Report *report;
+       DynStr *ds;
+       char *str;
+
+       if(!reports || !reports->list.first)
+               return;
+       if(!CTX_wm_window(C))
+               return;
+
+       ds= BLI_dynstr_new();
+
+       for(report=reports->list.first; report; report=report->next) {
+               if(report->type >= RPT_ERROR)
+                       BLI_dynstr_appendf(ds, "Error %%i%d%%t|%s", ICON_ERROR, report->message);
+               else if(report->type >= RPT_WARNING)
+                       BLI_dynstr_appendf(ds, "Warning %%i%d%%t|%s", ICON_ERROR, report->message);
+       }
+
+       str= BLI_dynstr_get_cstring(ds);
+       uiPupmenu(C, 0, NULL, NULL, str);
+       MEM_freeN(str);
+
+       BLI_dynstr_free(ds);
+}
+
index 337f553e246bee1a16126e54dc51d795c27e6e18..5b5ff95d37c357033c229fd99820556881f85bda 100644 (file)
@@ -907,7 +907,8 @@ void filelist_from_library(struct FileList* filelist)
 
 void filelist_append_library(struct FileList *filelist, char *dir, char *file, short flag, int idcode, struct Main *mainvar, struct Scene* scene)
 {
 
 void filelist_append_library(struct FileList *filelist, char *dir, char *file, short flag, int idcode, struct Main *mainvar, struct Scene* scene)
 {
-       BLO_library_append_(&filelist->libfiledata, filelist->filelist, filelist->numfiles, dir, file, flag, idcode, mainvar, scene);
+       // XXX todo: replace NULL with op->reports
+       BLO_library_append_(&filelist->libfiledata, filelist->filelist, filelist->numfiles, dir, file, flag, idcode, mainvar, scene, NULL);
 }
 
 void filelist_from_main(struct FileList *filelist)
 }
 
 void filelist_from_main(struct FileList *filelist)
index 1aec7856da42a4c1ea1adaed310744020378c5b8..f5b3ffbd687ee4b5b83465601c9a724bbf1a3431 100644 (file)
@@ -447,6 +447,23 @@ typedef struct SpaceImaSel {
 #define CONTEXT_SCRIPT 5
 #define CONTEXT_LOGIC  6
 
 #define CONTEXT_SCRIPT 5
 #define CONTEXT_LOGIC  6
 
+/* sbuts->mainb old */
+#define BUTS_VIEW                      0
+#define BUTS_LAMP                      1
+#define BUTS_MAT                       2
+#define BUTS_TEX                       3
+#define BUTS_ANIM                      4
+#define BUTS_WORLD                     5
+#define BUTS_RENDER                    6
+#define BUTS_EDIT                      7
+#define BUTS_GAME                      8
+#define BUTS_FPAINT                    9
+#define BUTS_RADIO                     10
+#define BUTS_SCRIPT                    11
+#define BUTS_SOUND                     12
+#define BUTS_CONSTRAINT                13
+#define BUTS_EFFECTS           14
+
 /* sbuts->tab new */
 #define TAB_SHADING_MAT        0
 #define TAB_SHADING_TEX        1
 /* sbuts->tab new */
 #define TAB_SHADING_MAT        0
 #define TAB_SHADING_TEX        1
@@ -471,6 +488,19 @@ typedef struct SpaceImaSel {
 #define BUT_HORIZONTAL  1
 #define BUT_VERTICAL    2
 
 #define BUT_HORIZONTAL  1
 #define BUT_VERTICAL    2
 
+/* sbuts->scaflag */           
+#define BUTS_SENS_SEL          1
+#define BUTS_SENS_ACT          2
+#define BUTS_SENS_LINK         4
+#define BUTS_CONT_SEL          8
+#define BUTS_CONT_ACT          16
+#define BUTS_CONT_LINK         32
+#define BUTS_ACT_SEL           64
+#define BUTS_ACT_ACT           128
+#define BUTS_ACT_LINK          256
+#define BUTS_SENS_STATE                512
+#define BUTS_ACT_STATE         1024
+
 /* these values need to be hardcoded in structs, dna does not recognize defines */
 /* also defined in BKE */
 #define FILE_MAXDIR                    160
 /* these values need to be hardcoded in structs, dna does not recognize defines */
 /* also defined in BKE */
 #define FILE_MAXDIR                    160
index 05ed8ab77c4ea614f23e42c0e7b1a1cbaf9be3a5..d4d54195146e1e9e50a344acc651b0e020ab3f78 100644 (file)
@@ -50,6 +50,7 @@ struct wmSubWindow;
 struct wmTimer;
 struct StructRNA;
 struct PointerRNA;
 struct wmTimer;
 struct StructRNA;
 struct PointerRNA;
+struct ReportList;
 
 /* windowmanager is saved, tag WMAN */
 typedef struct wmWindowManager {
 
 /* windowmanager is saved, tag WMAN */
 typedef struct wmWindowManager {
@@ -188,6 +189,7 @@ typedef struct wmOperator {
        wmOperatorType *type;           /* operator type definition from idname */
        void *customdata;                       /* custom storage, only while operator runs */
        struct PointerRNA *ptr;         /* rna pointer to access properties */
        wmOperatorType *type;           /* operator type definition from idname */
        void *customdata;                       /* custom storage, only while operator runs */
        struct PointerRNA *ptr;         /* rna pointer to access properties */
+       struct ReportList *reports;     /* errors and warnings storage */
 } wmOperator;
 
 /* operator type exec(), invoke() modal(), return values */
 } wmOperator;
 
 /* operator type exec(), invoke() modal(), return values */
index a28b3f8b86ec06ed4d78806638fb85e06ceda544..36198087d220f6551b9ca97ed886c200b5785da3 100644 (file)
@@ -50,8 +50,8 @@ wmWindow      *WM_window_open         (struct bContext *C, struct rcti *rect);
                        /* files */
 int                    WM_read_homefile        (struct bContext *C, int from_memory);
 int                    WM_write_homefile       (struct bContext *C, struct wmOperator *op);
                        /* files */
 int                    WM_read_homefile        (struct bContext *C, int from_memory);
 int                    WM_write_homefile       (struct bContext *C, struct wmOperator *op);
-void           WM_read_file            (struct bContext *C, char *name);
-void           WM_write_file           (struct bContext *C, char *target);
+void           WM_read_file            (struct bContext *C, char *name, struct ReportList *reports);
+void           WM_write_file           (struct bContext *C, char *target, struct ReportList *reports);
 void           WM_read_autosavefile(struct bContext *C);
 void           WM_write_autosave       (struct bContext *C);
 
 void           WM_read_autosavefile(struct bContext *C);
 void           WM_write_autosave       (struct bContext *C);
 
@@ -111,9 +111,6 @@ int                 WM_menu_invoke                  (struct bContext *C, struct wmOperator *op, struct wmEven
 int                    WM_operator_confirm             (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
                        /* poll callback, context checks */
 int                    WM_operator_winactive   (struct bContext *C);
 int                    WM_operator_confirm             (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
                        /* poll callback, context checks */
 int                    WM_operator_winactive   (struct bContext *C);
-       
-                       /* default error box */
-void           WM_error(struct bContext *C, char *str);
 
                /* operator api */
 void           WM_operator_free                (struct wmOperator *op);
 
                /* operator api */
 void           WM_operator_free                (struct wmOperator *op);
index 725e9cd989efd26b169fd19a367ffd4669a91fee..a5e11a12c5a5156e0484bd8995a32481d1a06e43 100644 (file)
 
 #include "BKE_blender.h"
 #include "BKE_context.h"
 
 #include "BKE_blender.h"
 #include "BKE_context.h"
+#include "BKE_idprop.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
-#include "BKE_idprop.h"
+#include "BKE_report.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -65,6 +66,11 @@ void WM_operator_free(wmOperator *op)
        if(op->ptr)
                MEM_freeN(op->ptr);
 
        if(op->ptr)
                MEM_freeN(op->ptr);
 
+       if(op->reports) {
+               BKE_reports_clear(op->reports);
+               MEM_freeN(op->reports);
+       }
+
        MEM_freeN(op);
 }
 
        MEM_freeN(op);
 }
 
index f241fb7f91e569102a1e363eeb1a0be6a2695c26..d76b7ebebd438df1995936a48a680237255ba1aa 100644 (file)
@@ -44,6 +44,7 @@
 #include "BKE_context.h"
 #include "BKE_idprop.h"
 #include "BKE_global.h"
 #include "BKE_context.h"
 #include "BKE_idprop.h"
 #include "BKE_global.h"
+#include "BKE_report.h"
 #include "BKE_utildefines.h"
 
 #include "ED_screen.h"
 #include "BKE_utildefines.h"
 
 #include "ED_screen.h"
@@ -52,6 +53,8 @@
 
 #include "RNA_access.h"
 
 
 #include "RNA_access.h"
 
+#include "UI_interface.h"
+
 #include "WM_api.h"
 #include "WM_types.h"
 #include "wm.h"
 #include "WM_api.h"
 #include "WM_types.h"
 #include "wm.h"
@@ -336,6 +339,10 @@ int WM_operator_call(bContext *C, wmOperator *op)
        
        if(op->type->exec)
                retval= op->type->exec(C, op);
        
        if(op->type->exec)
                retval= op->type->exec(C, op);
+
+       if(!(retval & OPERATOR_RUNNING_MODAL))
+               if(op->reports->list.first)
+                       uiPupmenuReports(C, op->reports);
        
        if((retval & OPERATOR_FINISHED) && (op->type->flag & OPTYPE_REGISTER)) {
                wm_operator_register(CTX_wm_manager(C), op);
        
        if((retval & OPERATOR_FINISHED) && (op->type->flag & OPTYPE_REGISTER)) {
                wm_operator_register(CTX_wm_manager(C), op);
@@ -364,6 +371,9 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, I
                op->ptr= MEM_callocN(sizeof(PointerRNA), "wmOperatorPtrRNA");
                RNA_pointer_create(&RNA_WindowManager, &wm->id, ot->srna, &op->properties, op->ptr);
 
                op->ptr= MEM_callocN(sizeof(PointerRNA), "wmOperatorPtrRNA");
                RNA_pointer_create(&RNA_WindowManager, &wm->id, ot->srna, &op->properties, op->ptr);
 
+               op->reports= MEM_callocN(sizeof(ReportList), "wmOperatorReportList");
+               BKE_reports_init(op->reports, RPT_STORE);
+
                if(op->type->invoke && event)
                        retval= (*op->type->invoke)(C, op, event);
                else if(op->type->exec)
                if(op->type->invoke && event)
                        retval= (*op->type->invoke)(C, op, event);
                else if(op->type->exec)
@@ -374,6 +384,10 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, I
                if(G.f & G_DEBUG)
                        WM_operator_print(op);
 
                if(G.f & G_DEBUG)
                        WM_operator_print(op);
 
+               if(!(retval & OPERATOR_RUNNING_MODAL))
+                       if(op->reports->list.first)
+                               uiPupmenuReports(C, op->reports);
+
                if((retval & OPERATOR_FINISHED) && (ot->flag & OPTYPE_REGISTER)) {
                        wm_operator_register(wm, op);
                }
                if((retval & OPERATOR_FINISHED) && (ot->flag & OPTYPE_REGISTER)) {
                        wm_operator_register(wm, op);
                }
@@ -588,6 +602,10 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
                                CTX_wm_area_set(C, NULL);
                                CTX_wm_region_set(C, NULL);
                        }
                                CTX_wm_area_set(C, NULL);
                                CTX_wm_region_set(C, NULL);
                        }
+
+                       if(!(retval & OPERATOR_RUNNING_MODAL))
+                               if(op->reports->list.first)
+                                       uiPupmenuReports(C, op->reports);
                        
                        if((retval & OPERATOR_FINISHED) && (ot->flag & OPTYPE_REGISTER)) {
                                wm_operator_register(CTX_wm_manager(C), op);
                        
                        if((retval & OPERATOR_FINISHED) && (ot->flag & OPTYPE_REGISTER)) {
                                wm_operator_register(CTX_wm_manager(C), op);
index 2c05ce07f48bdde0b8f77971badf26ac16c4824c..02c457512464b239887a95ada71cc35e669de5db 100644 (file)
@@ -481,7 +481,7 @@ static void verse_unsub(void)
 }
 #endif
 
 }
 #endif
 
-void WM_read_file(bContext *C, char *name)
+void WM_read_file(bContext *C, char *name, ReportList *reports)
 {
        int retval;
 
 {
        int retval;
 
@@ -501,7 +501,7 @@ void WM_read_file(bContext *C, char *name)
                /* put aside screens to match with persistant windows later */
                wm_window_match_init(C, &wmbase); 
                
                /* put aside screens to match with persistant windows later */
                wm_window_match_init(C, &wmbase); 
                
-               retval= BKE_read_file(C, name, NULL);
+               retval= BKE_read_file(C, name, NULL, reports);
 
                /* match the read WM with current WM */
                wm_window_match_do(C, &wmbase); 
 
                /* match the read WM with current WM */
                wm_window_match_do(C, &wmbase); 
@@ -524,8 +524,10 @@ void WM_read_file(bContext *C, char *name)
        }
 //     else if(retval==1)
 // XXX         BIF_undo_push("Import file");
        }
 //     else if(retval==1)
 // XXX         BIF_undo_push("Import file");
-       else if(retval == -1) 
-               WM_error(C, "Cannot read file");
+       else if(retval == -1) {
+               if(reports && reports->list.first == NULL)
+                       BKE_report(reports, RPT_ERROR, "Cannot read file.");
+       }
 }
 
 static void outliner_242_patch(void)
 }
 
 static void outliner_242_patch(void)
@@ -573,9 +575,9 @@ int WM_read_homefile(bContext *C, int from_memory)
        wm_window_match_init(C, &wmbase); 
        
        if (!from_memory && BLI_exists(tstr)) {
        wm_window_match_init(C, &wmbase); 
        
        if (!from_memory && BLI_exists(tstr)) {
-               success = BKE_read_file(C, tstr, NULL);
+               success = BKE_read_file(C, tstr, NULL, NULL);
        } else {
        } else {
-               success = BKE_read_file_from_memory(C, datatoc_B_blend, datatoc_B_blend_size, NULL);
+               success = BKE_read_file_from_memory(C, datatoc_B_blend, datatoc_B_blend_size, NULL, NULL);
                /* outliner patch for 2.42 .b.blend */
                outliner_242_patch();
        }
                /* outliner patch for 2.42 .b.blend */
                outliner_242_patch();
        }
@@ -643,7 +645,7 @@ void WM_read_autosavefile(bContext *C)
        get_autosave_location(tstr);
 
        save_over = G.save_over;
        get_autosave_location(tstr);
 
        save_over = G.save_over;
-       BKE_read_file(C, tstr, NULL);
+       BKE_read_file(C, tstr, NULL, NULL);
        G.save_over = save_over;
        BLI_strncpy(G.sce, scestr, FILE_MAX);
 }
        G.save_over = save_over;
        BLI_strncpy(G.sce, scestr, FILE_MAX);
 }
@@ -781,7 +783,7 @@ static void writeBlog(void)
        }
 }
 
        }
 }
 
-static void do_history(char *name)
+static void do_history(char *name, ReportList *reports)
 {
        char tempname1[FILE_MAXDIR+FILE_MAXFILE], tempname2[FILE_MAXDIR+FILE_MAXFILE];
        int hisnr= U.versions;
 {
        char tempname1[FILE_MAXDIR+FILE_MAXFILE], tempname2[FILE_MAXDIR+FILE_MAXFILE];
        int hisnr= U.versions;
@@ -789,12 +791,12 @@ static void do_history(char *name)
        if(U.versions==0) return;
        if(strlen(name)<2) return;
                
        if(U.versions==0) return;
        if(strlen(name)<2) return;
                
-       while(  hisnr > 1) {
+       while(hisnr > 1) {
                sprintf(tempname1, "%s%d", name, hisnr-1);
                sprintf(tempname2, "%s%d", name, hisnr);
        
                sprintf(tempname1, "%s%d", name, hisnr-1);
                sprintf(tempname2, "%s%d", name, hisnr);
        
-//             if(BLI_rename(tempname1, tempname2))
-// XXX                 error("Unable to make version backup");
+               if(BLI_rename(tempname1, tempname2))
+                       BKE_report(reports, RPT_ERROR, "Unable to make version backup");
                        
                hisnr--;
        }
                        
                hisnr--;
        }
@@ -802,22 +804,21 @@ static void do_history(char *name)
        /* is needed when hisnr==1 */
        sprintf(tempname1, "%s%d", name, hisnr);
        
        /* is needed when hisnr==1 */
        sprintf(tempname1, "%s%d", name, hisnr);
        
-//     if(BLI_rename(name, tempname1))
-// XXX         error("Unable to make version backup");
+       if(BLI_rename(name, tempname1))
+               BKE_report(reports, RPT_ERROR, "Unable to make version backup");
 }
 
 }
 
-void WM_write_file(bContext *C, char *target)
+void WM_write_file(bContext *C, char *target, ReportList *reports)
 {
        Library *li;
        int writeflags, len;
        char di[FILE_MAX];
 {
        Library *li;
        int writeflags, len;
        char di[FILE_MAX];
-       ReportList reports;
        
        len = strlen(target);
        
        if (len == 0) return;
        if (len >= FILE_MAX) {
        
        len = strlen(target);
        
        if (len == 0) return;
        if (len >= FILE_MAX) {
-// XXX         error("Path too long, cannot save");
+               BKE_report(reports, RPT_ERROR, "Path too long, cannot save");
                return;
        }
  
                return;
        }
  
@@ -826,7 +827,7 @@ void WM_write_file(bContext *C, char *target)
 
        for (li= G.main->library.first; li; li= li->id.next) {
                if (BLI_streq(li->name, target)) {
 
        for (li= G.main->library.first; li; li= li->id.next) {
                if (BLI_streq(li->name, target)) {
-// XXX                 error("Cannot overwrite used library");
+                       BKE_report(reports, RPT_ERROR, "Cannot overwrite used library");
                        return;
                }
        }
                        return;
                }
        }
@@ -851,16 +852,14 @@ void WM_write_file(bContext *C, char *target)
        
 // XXX waitcursor(1);  // exit_editmode sets cursor too
 
        
 // XXX waitcursor(1);  // exit_editmode sets cursor too
 
-       do_history(di);
+       do_history(di, reports);
        
        /* we use the UserDef to define compression flag */
        writeflags= G.fileflags & ~G_FILE_COMPRESS;
        if(U.flag & USER_FILECOMPRESS)
                writeflags |= G_FILE_COMPRESS;
        
        /* we use the UserDef to define compression flag */
        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(CTX_data_main(C), di, writeflags, &reports)) {
+       if (BLO_write_file(CTX_data_main(C), di, writeflags, reports)) {
                strcpy(G.sce, di);
                G.relbase_valid = 1;
                strcpy(G.main->name, di);       /* is guaranteed current file */
                strcpy(G.sce, di);
                G.relbase_valid = 1;
                strcpy(G.main->name, di);       /* is guaranteed current file */
@@ -870,38 +869,29 @@ void WM_write_file(bContext *C, char *target)
                G.save_over = 1;
 
                writeBlog();
                G.save_over = 1;
 
                writeBlog();
-       } else {
-// XXX         error("%s", err);
        }
 
        }
 
-       BKE_reports_clear(&reports);
-
 // XXX waitcursor(0);
 }
 
 /* operator entry */
 int WM_write_homefile(bContext *C, wmOperator *op)
 {
 // XXX waitcursor(0);
 }
 
 /* operator entry */
 int WM_write_homefile(bContext *C, wmOperator *op)
 {
-       ReportList reports;
        char tstr[FILE_MAXDIR+FILE_MAXFILE];
        int write_flags;
        
        char tstr[FILE_MAXDIR+FILE_MAXFILE];
        int write_flags;
        
-       BLI_make_file_string("/", tstr, BLI_gethome(), ".B.blend");
+       BLI_make_file_string("/", tstr, "/", ".B.blend");
                
        /*  force save as regular blend file */
        write_flags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN);
 
                
        /*  force save as regular blend file */
        write_flags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN);
 
-       // XXX error reporting to the user
-       BKE_reports_init(&reports, RPT_PRINT);
-       BLO_write_file(CTX_data_main(C), tstr, write_flags, &reports);
-       BKE_reports_clear(&reports);
+       BLO_write_file(CTX_data_main(C), tstr, write_flags, op->reports);
        
        return OPERATOR_FINISHED;
 }
 
 void WM_write_autosave(bContext *C)
 {
        
        return OPERATOR_FINISHED;
 }
 
 void WM_write_autosave(bContext *C)
 {
-       ReportList reports;
        char tstr[FILE_MAXDIR+FILE_MAXFILE];
        int write_flags;
        
        char tstr[FILE_MAXDIR+FILE_MAXFILE];
        int write_flags;
        
@@ -910,9 +900,8 @@ void WM_write_autosave(bContext *C)
                /*  force save as regular blend file */
        write_flags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN);
 
                /*  force save as regular blend file */
        write_flags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN);
 
-       BKE_reports_init(&reports, RPT_PRINT);
-       BLO_write_file(CTX_data_main(C), tstr, write_flags, &reports);
-       BKE_reports_clear(&reports);
+               /* error reporting to console */
+       BLO_write_file(CTX_data_main(C), tstr, write_flags, NULL);
 }
 
 /* if global undo; remove tempsave, otherwise rename */
 }
 
 /* if global undo; remove tempsave, otherwise rename */
@@ -933,7 +922,3 @@ void delete_autosave(void)
 
 /***/
 
 
 /***/
 
-
-
-
-
index 236efb8f8e4e135f640792204766021dbdc1f1c5..7d2c4a12ef4c83a1a4a22b7eb5cfbe520166cbb2 100644 (file)
@@ -195,17 +195,6 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
        return OPERATOR_CANCELLED;
 }
 
        return OPERATOR_CANCELLED;
 }
 
-/* call anywhere */
-void WM_error(bContext *C, char *str)
-{
-       char buf[148], testbuf[128];
-       
-       BLI_strncpy(testbuf, str, 128);
-       sprintf(buf, "Error %%i%d%%t|%s", ICON_ERROR, testbuf);
-       uiPupmenu(C, 0, NULL, NULL, buf);
-       
-}
-
 /* op->invoke */
 int WM_operator_confirm(bContext *C, wmOperator *op, wmEvent *event)
 {
 /* op->invoke */
 int WM_operator_confirm(bContext *C, wmOperator *op, wmEvent *event)
 {
@@ -276,11 +265,11 @@ static int recentfile_exec(bContext *C, wmOperator *op)
        
        if(event>0) {
                if (G.sce[0] && (event==1))
        
        if(event>0) {
                if (G.sce[0] && (event==1))
-                       WM_read_file(C, G.sce);
+                       WM_read_file(C, G.sce, op->reports);
                else {
                        struct RecentFile *recent = BLI_findlink(&(G.recent_files), event-2);
                        if(recent) {
                else {
                        struct RecentFile *recent = BLI_findlink(&(G.recent_files), event-2);
                        if(recent) {
-                               WM_read_file(C, recent->filename);
+                               WM_read_file(C, recent->filename, op->reports);
                        }
                }
        }
                        }
                }
        }
index 0d0f4f7bb01875fb6572c18eb020ae3d6fc113cb..6e62fe10d40ed8e3efa6a5ed85cab988ec786d2e 100644 (file)
@@ -61,6 +61,7 @@
 #include "BKE_packedFile.h"
 #include "BKE_scene.h"
 #include "BKE_node.h"
 #include "BKE_packedFile.h"
 #include "BKE_scene.h"
 #include "BKE_node.h"
+#include "BKE_report.h"
 
 #include "IMB_imbuf.h" // for quicktime_init
 
 
 #include "IMB_imbuf.h" // for quicktime_init
 
@@ -71,9 +72,8 @@
 #include "RE_pipeline.h"
 
 //XXX #include "playanim_ext.h"
 #include "RE_pipeline.h"
 
 //XXX #include "playanim_ext.h"
-#include "wm_event_types.h"
 #include "ED_datafiles.h"
 #include "ED_datafiles.h"
-//XXX #include "datatoc.h"
+#include "UI_interface.h"
 
 #include "WM_api.h"
 
 
 #include "WM_api.h"
 
@@ -784,7 +784,7 @@ int main(int argc, char **argv)
                        BLI_convertstringcwd(filename);
                        
                        if (G.background) {
                        BLI_convertstringcwd(filename);
                        
                        if (G.background) {
-                               int retval = BKE_read_file(C, argv[a], NULL);
+                               int retval = BKE_read_file(C, argv[a], NULL, NULL);
 // XXX                 sound_initialize_sounds();
                                
                                /*we successfully loaded a blend file, get sure that
 // XXX                 sound_initialize_sounds();
                                
                                /*we successfully loaded a blend file, get sure that
@@ -797,7 +797,7 @@ int main(int argc, char **argv)
                        } else {
                                /* we are not running in background mode here, but start blender in UI mode with 
                                   a file - this should do everything a 'load file' does */
                        } else {
                                /* we are not running in background mode here, but start blender in UI mode with 
                                   a file - this should do everything a 'load file' does */
-                               WM_read_file(C, filename);
+                               WM_read_file(C, filename, NULL);
                        }
                }
        }
                        }
                }
        }
@@ -827,7 +827,7 @@ static void error_cb(char *err)
 
 static void mem_error_cb(char *errorStr)
 {
 
 static void mem_error_cb(char *errorStr)
 {
-       fprintf(stderr, errorStr);
+       fprintf(stderr, "%s", errorStr);
        fflush(stderr);
 }
 
        fflush(stderr);
 }