[Bf-blender-cvs] [49915e32418] master: Cleanup: validate G.main's in creator code.

Bastien Montagne noreply at git.blender.org
Fri Jun 15 17:37:23 CEST 2018


Commit: 49915e3241839045f8e688edab1ce314edc465f4
Author: Bastien Montagne
Date:   Fri Jun 15 17:36:44 2018 +0200
Branches: master
https://developer.blender.org/rB49915e3241839045f8e688edab1ce314edc465f4

Cleanup: validate G.main's in creator code.

Using G_MAIN here is valid!

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

M	source/creator/creator_args.c
M	source/creator/creator_signals.c

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

diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index 4f2185cae96..98147e45c4e 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -404,7 +404,7 @@ static void arg_py_context_restore(
 	/* script may load a file, check old data is valid before using */
 	if (c_py->has_win) {
 		if ((c_py->win == NULL) ||
-		    ((BLI_findindex(&G.main->wm, c_py->wm) != -1) &&
+		    ((BLI_findindex(&G_MAIN->wm, c_py->wm) != -1) &&
 		     (BLI_findindex(&c_py->wm->windows, c_py->win) != -1)))
 		{
 			CTX_wm_window_set(C, c_py->win);
@@ -412,7 +412,7 @@ static void arg_py_context_restore(
 	}
 
 	if ((c_py->scene == NULL) ||
-	    BLI_findindex(&G.main->scene, c_py->scene) != -1)
+	    BLI_findindex(&G_MAIN->scene, c_py->scene) != -1)
 	{
 		CTX_data_scene_set(C, c_py->scene);
 	}
@@ -1914,7 +1914,7 @@ static int arg_handle_load_file(int UNUSED(argc), const char **argv, void *data)
 
 		if (BLO_has_bfile_extension(filename)) {
 			/* Just pretend a file was loaded, so the user can press Save and it'll save at the filename from the CLI. */
-			BLI_strncpy(G.main->name, filename, FILE_MAX);
+			BLI_strncpy(G_MAIN->name, filename, FILE_MAX);
 			G.relbase_valid = true;
 			G.save_over = true;
 			printf("... opened default scene instead; saving will write to: %s\n", filename);
diff --git a/source/creator/creator_signals.c b/source/creator/creator_signals.c
index feb108da289..d1f51405330 100644
--- a/source/creator/creator_signals.c
+++ b/source/creator/creator_signals.c
@@ -117,7 +117,7 @@ static void sig_handle_crash_backtrace(FILE *fp)
 
 static void sig_handle_crash(int signum)
 {
-	wmWindowManager *wm = G.main->wm.first;
+	wmWindowManager *wm = G_MAIN->wm.first;
 
 #ifdef USE_WRITE_CRASH_BLEND
 	if (wm->undo_stack) {
@@ -125,11 +125,11 @@ static void sig_handle_crash(int signum)
 		if (memfile) {
 			char fname[FILE_MAX];
 
-			if (!G.main->name[0]) {
+			if (!G_MAIN->name[0]) {
 				BLI_make_file_string("/", fname, BKE_tempdir_base(), "crash.blend");
 			}
 			else {
-				BLI_strncpy(fname, G.main->name, sizeof(fname));
+				BLI_strncpy(fname, G_MAIN->name, sizeof(fname));
 				BLI_replace_extension(fname, sizeof(fname), ".crash.blend");
 			}
 
@@ -146,11 +146,11 @@ static void sig_handle_crash(int signum)
 
 	char fname[FILE_MAX];
 
-	if (!G.main->name[0]) {
+	if (!G_MAIN->name[0]) {
 		BLI_join_dirfile(fname, sizeof(fname), BKE_tempdir_base(), "blender.crash.txt");
 	}
 	else {
-		BLI_join_dirfile(fname, sizeof(fname), BKE_tempdir_base(), BLI_path_basename(G.main->name));
+		BLI_join_dirfile(fname, sizeof(fname), BKE_tempdir_base(), BLI_path_basename(G_MAIN->name));
 		BLI_replace_extension(fname, sizeof(fname), ".crash.txt");
 	}



More information about the Bf-blender-cvs mailing list