Reporting was done before before addons were loaded
authorCampbell Barton <ideasman42@gmail.com>
Tue, 22 Sep 2015 06:45:23 +0000 (16:45 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 22 Sep 2015 06:53:07 +0000 (16:53 +1000)
On the very first start, reporting of missing engines wasn't working.

source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_window.c
source/blender/windowmanager/wm_files.h

index 98ea8b903b4243d3156ff59dfe3e4a35a3c33587..d08c6c59a7f53989b0ff4f2fac56cd126b295101 100644 (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) {
index 1f5a2767dd58f5c7e05dc11dd21222b19b6fddef..ba4a807dbd7a94c44bb088810bf152a4ee57c18f 100644 (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);
+               }
        }
 }
 
index a03f2c22055aedcce5742b0ef844709f9aec66b3..3120cfc4f5295a4812025ce428eda78265f1ebfe 100644 (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;
index 467926aa770b2fc56f45fc1357b1322e431747c3..4b35f662a99f01a4ebb59305c6ad2dd6c6fb78e4 100644 (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__ */