new command line option '--factory-startup' to skip reading startup.blend. useful for testing with a predictable environment.

also commented python benchmark prints on exit, can enable when profiling later.
This commit is contained in:
Campbell Barton 2011-01-19 09:13:24 +00:00
parent dddb9aa30f
commit 161cbed9b5
9 changed files with 36 additions and 18 deletions

@ -1,4 +1,4 @@
.TH "BLENDER" "1" "January 01, 2011" "Blender Blender 2\&.56 (sub 0) "
.TH "BLENDER" "1" "January 19, 2011" "Blender Blender 2\&.56 (sub 0) "
.SH NAME
blender \- a 3D modelling and rendering package
@ -208,6 +208,12 @@ Turn debugging on
Enable floating point exceptions
.br
.TP
.B \-\-factory\-startup
.br
Skip reading the "startup.blend" in the users home directory
.br
.IP
.TP

@ -61,7 +61,8 @@ typedef struct Global {
struct ListBase recent_files;
short afbreek, moving, file_loaded;
short background;
char background;
char factory_startup;
short winpos, displaymode; /* used to be in Render */
short rendering; /* to indicate render is busy, prevent renderwindow events etc */

@ -1015,7 +1015,7 @@ void init_userdef_do_versions(void)
}
if (U.savetime <= 0) {
U.savetime = 1;
// XXX error("startup.blend is buggy, please consider removing it.\n");
// XXX error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n");
}
/* transform widget settings */
if(U.tw_hotspot==0) {

@ -62,8 +62,7 @@
static int py_call_level= 0;
BPy_StructRNA *bpy_context_module= NULL; /* for fast access */
// only for tests
#define TIME_PY_RUN
// #define TIME_PY_RUN // simple python tests. prints on exit.
#ifdef TIME_PY_RUN
#include "PIL_time.h"

@ -81,7 +81,8 @@ void WM_window_open_temp (struct bContext *C, struct rcti *position, int type);
/* files */
int WM_read_homefile (struct bContext *C, struct wmOperator *op);
int WM_read_homefile_exec(struct bContext *C, struct wmOperator *op);
int WM_read_homefile (struct bContext *C, struct ReportList *reports, short from_memory);
int WM_write_homefile (struct bContext *C, struct wmOperator *op);
void WM_read_file (struct bContext *C, const char *name, struct ReportList *reports);
int WM_write_file (struct bContext *C, const char *target, int fileflags, struct ReportList *reports, int copy);

@ -352,11 +352,10 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports)
/* called on startup, (context entirely filled with NULLs) */
/* or called for 'New File' */
/* op can be NULL */
int WM_read_homefile(bContext *C, wmOperator *op)
int WM_read_homefile(bContext *C, ReportList *reports, short from_memory)
{
ListBase wmbase;
char tstr[FILE_MAXDIR+FILE_MAXFILE];
int from_memory= op && strcmp(op->type->idname, "WM_OT_read_factory_settings")==0;
int success= 0;
free_ttfont(); /* still weird... what does it here? */
@ -369,9 +368,7 @@ int WM_read_homefile(bContext *C, wmOperator *op)
} else {
tstr[0] = '\0';
from_memory = 1;
if (op) {
BKE_report(op->reports, RPT_INFO, "Config directory with startup.blend file not found.");
}
BKE_report(reports, RPT_INFO, "Config directory with "STRINGIFY(BLENDER_STARTUP_FILE)" file not found.");
}
}
@ -385,7 +382,7 @@ int WM_read_homefile(bContext *C, wmOperator *op)
success = (BKE_read_file(C, tstr, NULL) != BKE_READ_FILE_FAIL);
if(U.themes.first==NULL) {
printf("\nError: No valid startup.blend, fall back to built-in default.\n\n");
printf("\nError: No valid "STRINGIFY(BLENDER_STARTUP_FILE)", fall back to built-in default.\n\n");
success = 0;
}
}
@ -436,9 +433,14 @@ int WM_read_homefile(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL);
CTX_wm_window_set(C, NULL); /* exits queues */
return OPERATOR_FINISHED;
return TRUE;
}
int WM_read_homefile_exec(bContext *C, wmOperator *op)
{
int from_memory= strcmp(op->type->idname, "WM_OT_read_factory_settings") == 0;
return WM_read_homefile(C, op->reports, from_memory) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
void read_history(void)
{

@ -136,7 +136,7 @@ void WM_init(bContext *C, int argc, char **argv)
BLF_lang_init();
/* get the default database, plus a wm */
WM_read_homefile(C, NULL);
WM_read_homefile(C, NULL, G.factory_startup);
/* note: there is a bug where python needs initializing before loading the
* startup.blend because it may contain PyDrivers. It also needs to be after

@ -1353,7 +1353,7 @@ static void WM_OT_read_homefile(wmOperatorType *ot)
ot->description="Open the default file (doesn't save the current file)";
ot->invoke= WM_operator_confirm;
ot->exec= WM_read_homefile;
ot->exec= WM_read_homefile_exec;
ot->poll= WM_operator_winactive;
}
@ -1364,7 +1364,7 @@ static void WM_OT_read_factory_settings(wmOperatorType *ot)
ot->description="Load default file and user preferences";
ot->invoke= WM_operator_confirm;
ot->exec= WM_read_homefile;
ot->exec= WM_read_homefile_exec;
ot->poll= WM_operator_winactive;
}

@ -245,6 +245,7 @@ static int print_help(int UNUSED(argc), char **UNUSED(argv), void *data)
printf ("Misc Options:\n");
BLI_argsPrintArgDoc(ba, "--debug");
BLI_argsPrintArgDoc(ba, "--debug-fpe");
BLI_argsPrintArgDoc(ba, "--factory-startup");
printf("\n");
@ -392,6 +393,12 @@ static int set_fpe(int UNUSED(argc), char **UNUSED(argv), void *UNUSED(data))
return 0;
}
static int set_factory_startup(int UNUSED(argc), char **UNUSED(argv), void *UNUSED(data))
{
G.factory_startup= 1;
return 0;
}
static int playback_mode(int UNUSED(argc), char **UNUSED(argv), void *UNUSED(data))
{
/* not if -b was given first */
@ -1006,7 +1013,9 @@ void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle)
BLI_argsAdd(ba, 1, "-a", NULL, playback_doc, playback_mode, NULL);
BLI_argsAdd(ba, 1, "-d", "--debug", debug_doc, debug_mode, ba);
BLI_argsAdd(ba, 1, NULL, "--debug-fpe", "\n\tEnable floating point exceptions", set_fpe, NULL);
BLI_argsAdd(ba, 1, NULL, "--debug-fpe", "\n\tEnable floating point exceptions", set_fpe, NULL);
BLI_argsAdd(ba, 1, NULL, "--factory-startup", "\n\tSkip reading the "STRINGIFY(BLENDER_STARTUP_FILE)" in the users home directory", set_factory_startup, NULL);
/* second pass: custom window stuff */
BLI_argsAdd(ba, 2, "-p", "--window-geometry", "<sx> <sy> <w> <h>\n\tOpen with lower left corner at <sx>, <sy> and width and height as <w>, <h>", prefsize, NULL);
@ -1139,7 +1148,7 @@ int main(int argc, char **argv)
BLI_argsParse(ba, 3, NULL, NULL);
WM_init(C, argc, argv);
/* this is properly initialized with user defs, but this is default */
BLI_where_is_temp( btempdir, 1 ); /* call after loading the startup.blend so we can read U.tempdir */