[Bf-blender-cvs] [e29f8c6] master: Reporting was done before before addons were loaded

Campbell Barton noreply at git.blender.org
Tue Sep 22 08:58:44 CEST 2015


Commit: e29f8c600b729e42ccdf5427e79ec4d8768dd0bf
Author: Campbell Barton
Date:   Tue Sep 22 16:45:23 2015 +1000
Branches: master
https://developer.blender.org/rBe29f8c600b729e42ccdf5427e79ec4d8768dd0bf

Reporting was done before before addons were loaded

On the very first start, reporting of missing engines wasn't working.

===================================================================

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

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 98ea8b9..d08c6c5 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -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) {
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 1f5a276..ba4a807 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -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);
+		}
 	}
 }
 
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index a03f2c2..3120cfc 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -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;
diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h
index 467926a..4b35f66 100644
--- a/source/blender/windowmanager/wm_files.h
+++ b/source/blender/windowmanager/wm_files.h
@@ -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__ */




More information about the Bf-blender-cvs mailing list