2.5: Error reporting

* 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.
This commit is contained in:
2008-12-29 13:38:08 +00:00
parent d51bc24384
commit 0a8a00cd10
23 changed files with 340 additions and 227 deletions

View File

@@ -40,6 +40,7 @@ struct AutoComplete;
struct bContext;
struct PointerRNA;
struct PropertyRNA;
struct ReportList;
/* 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 uiPupmenuReports(struct bContext *C, struct ReportList *reports);
/* Block */

View File

@@ -36,8 +36,10 @@
#include "BLI_arithb.h"
#include "BLI_blenlib.h"
#include "BLI_dynstr.h"
#include "BKE_context.h"
#include "BKE_report.h"
#include "BKE_screen.h"
#include "BKE_utildefines.h"
@@ -1765,3 +1767,30 @@ void uiPupmenuError(bContext *C, char *str, ...)
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);
}

View 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)
{
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)