Reporting was done before before addons were loaded

On the very first start, reporting of missing engines wasn't working.
This commit is contained in:
Campbell Barton 2015-09-22 16:45:23 +10:00
parent b87cb9ad2c
commit e29f8c600b
4 changed files with 47 additions and 26 deletions

View File

@ -404,12 +404,40 @@ void WM_file_autoexec_init(const char *filepath)
}
}
void wm_file_read_report(bContext *C)
{
ReportList *reports = NULL;
Scene *sce;
for (sce = G.main->scene.first; sce; sce = sce->id.next) {
if (sce->r.engine[0] &&
BLI_findstring(&R_engines, sce->r.engine, offsetof(RenderEngineType, idname)) == NULL)
{
if (reports == NULL) {
reports = CTX_wm_reports(C);
}
BKE_reportf(reports, RPT_ERROR,
"Engine '%s' not available for scene '%s' "
"(an addon may need to be installed or enabled)",
sce->r.engine, sce->id.name + 2);
}
}
if (reports) {
if (!G.background) {
WM_report_banner_show(C);
}
}
}
/**
* Logic shared between #WM_file_read & #wm_homefile_read,
* updates to make after reading a file.
*/
static void wm_file_read_post(bContext *C, bool is_startup_file)
{
bool addons_loaded = false;
CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first);
ED_editors_init(C);
@ -423,11 +451,13 @@ static void wm_file_read_post(bContext *C, bool is_startup_file)
BPY_string_exec(C, "__import__('addon_utils').reset_all()");
BPY_python_reset(C);
addons_loaded = true;
}
}
else {
/* run any texts that were loaded in and flagged as modules */
BPY_python_reset(C);
addons_loaded = true;
}
#endif /* WITH_PYTHON */
@ -439,31 +469,10 @@ static void wm_file_read_post(bContext *C, bool is_startup_file)
WM_event_add_notifier(C, NC_WM | ND_FILEREAD, NULL);
/* report any errors */
{
ReportList *reports = NULL;
Scene *sce;
for (sce = G.main->scene.first; sce; sce = sce->id.next) {
if (sce->r.engine[0] &&
BLI_findstring(&R_engines, sce->r.engine, offsetof(RenderEngineType, idname)) == NULL)
{
if (reports == NULL) {
reports = CTX_wm_reports(C);
}
BKE_reportf(reports, RPT_ERROR,
"Engine '%s' not available for scene '%s' "
"(an addon may need to be installed or enabled)",
sce->r.engine, sce->id.name + 2);
}
}
if (reports) {
if (!G.background) {
WM_report_banner_show(C);
}
}
/* report any errors.
* currently disabled if addons aren't yet loaded */
if (addons_loaded) {
wm_file_read_report(C);
}
if (!G.background) {

View File

@ -261,13 +261,24 @@ void WM_init(bContext *C, int argc, const char **argv)
/* that prevents loading both the kept session, and the file on the command line */
}
else {
/* note, logic here is from wm_file_read_post,
* call functions that depend on Python being initialized. */
/* normally 'wm_homefile_read' will do this,
* however python is not initialized when called from this function.
*
* unlikely any handlers are set but its possible,
* note that recovering the last session does its own callbacks. */
CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first);
BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_VERSION_UPDATE);
BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST);
wm_file_read_report(C);
if (!G.background) {
CTX_wm_window_set(C, NULL);
}
}
}

View File

@ -1278,7 +1278,7 @@ void WM_event_timer_sleep(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *t
wmTimer *WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)
{
wmTimer *wt = MEM_callocN(sizeof(wmTimer), "window timer");
wt->event_type = event_type;
wt->ltime = PIL_check_seconds_timer();
wt->ntime = wt->ltime + timestep;

View File

@ -38,6 +38,7 @@ int wm_homefile_read_exec(struct bContext *C, struct wmOperator *op);
int wm_homefile_read(struct bContext *C, struct ReportList *reports, bool from_memory, const char *filepath);
int wm_homefile_write_exec(struct bContext *C, struct wmOperator *op);
int wm_userpref_write_exec(struct bContext *C, struct wmOperator *op);
void wm_file_read_report(bContext *C);
#endif /* __WM_FILES_H__ */