[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47977] trunk/blender/source/creator/ creator.c: fix for running blender as a python module - dont parse args from python.

Campbell Barton ideasman42 at gmail.com
Fri Jun 15 23:19:06 CEST 2012


Revision: 47977
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47977
Author:   campbellbarton
Date:     2012-06-15 21:19:05 +0000 (Fri, 15 Jun 2012)
Log Message:
-----------
fix for running blender as a python module - dont parse args from python.

Modified Paths:
--------------
    trunk/blender/source/creator/creator.c

Modified: trunk/blender/source/creator/creator.c
===================================================================
--- trunk/blender/source/creator/creator.c	2012-06-15 20:59:00 UTC (rev 47976)
+++ trunk/blender/source/creator/creator.c	2012-06-15 21:19:05 UTC (rev 47977)
@@ -145,8 +145,10 @@
 #endif
 
 /*	Local Function prototypes */
+#ifndef WITH_PYTHON_MODULE
 static int print_help(int argc, const char **argv, void *data);
 static int print_version(int argc, const char **argv, void *data);
+#endif
 
 /* for the callbacks: */
 
@@ -157,6 +159,8 @@
 /* Initialize callbacks for the modules that need them */
 static void setCallbacks(void); 
 
+#ifndef WITH_PYTHON_MODULE
+
 /* set breakpoints here when running in debug mode, useful to catch floating point errors */
 #if defined(__linux__) || defined(_WIN32) || defined(OSX_SSE_FPE)
 static void fpe_handler(int UNUSED(sig))
@@ -165,7 +169,6 @@
 }
 #endif
 
-#ifndef WITH_PYTHON_MODULE
 /* handling ctrl-c event in console */
 static void blender_esc(int sig)
 {
@@ -182,7 +185,6 @@
 		count++;
 	}
 }
-#endif
 
 static int print_version(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
 {
@@ -972,7 +974,6 @@
 	}
 }
 
-
 static int load_file(int UNUSED(argc), const char **argv, void *data)
 {
 	bContext *C = data;
@@ -1171,6 +1172,7 @@
 	BLI_argsAdd(ba, 4, "-x", "--use-extension", "<bool>\n\tSet option to add the file extension to the end of the file", set_extension, C);
 
 }
+#endif /* WITH_PYTHON_MODULE */
 
 #ifdef WITH_PYTHON_MODULE
 /* allow python module to call main */
@@ -1191,9 +1193,12 @@
 int main(int argc, const char **argv)
 #endif
 {
+	bContext *C = CTX_create();
 	SYS_SystemHandle syshandle;
-	bContext *C = CTX_create();
+
+#ifndef WITH_PYTHON_MODULE
 	bArgs *ba;
+#endif
 
 #ifdef WIN32
 	wchar_t **argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc);
@@ -1268,10 +1273,12 @@
 #endif
 
 	/* first test for background */
+#ifndef WITH_PYTHON_MODULE
 	ba = BLI_argsInit(argc, (const char **)argv); /* skip binary path */
 	setupArguments(C, ba, &syshandle);
 
 	BLI_argsParse(ba, 1, NULL, NULL);
+#endif
 
 #if defined(WITH_PYTHON_MODULE) || defined(WITH_HEADLESS)
 	G.background = 1; /* python module mode ALWAYS runs in background mode (for now) */
@@ -1290,9 +1297,10 @@
 	init_def_material();
 
 	if (G.background == 0) {
+#ifndef WITH_PYTHON_MODULE
 		BLI_argsParse(ba, 2, NULL, NULL);
 		BLI_argsParse(ba, 3, NULL, NULL);
-
+#endif
 		WM_init(C, argc, (const char **)argv);
 
 		/* this is properly initialized with user defs, but this is default */
@@ -1304,7 +1312,9 @@
 #endif
 	}
 	else {
+#ifndef WITH_PYTHON_MODULE
 		BLI_argsParse(ba, 3, NULL, NULL);
+#endif
 
 		WM_init(C, argc, (const char **)argv);
 
@@ -1328,9 +1338,13 @@
 	WM_keymap_init(C);
 
 	/* OK we are ready for it */
+#ifndef WITH_PYTHON_MODULE
 	BLI_argsParse(ba, 4, load_file, C);
+#endif
 
+#ifndef WITH_PYTHON_MODULE
 	BLI_argsFree(ba);
+#endif
 
 #ifdef WIN32
 	while (argci) {




More information about the Bf-blender-cvs mailing list