diff options
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/SConscript | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 29 |
3 files changed, 23 insertions, 11 deletions
diff --git a/source/blender/windowmanager/SConscript b/source/blender/windowmanager/SConscript index 3a813d7d598..0a2f48f0488 100644 --- a/source/blender/windowmanager/SConscript +++ b/source/blender/windowmanager/SConscript @@ -78,4 +78,7 @@ if env['WITH_BF_INTERNATIONAL']: if env['WITH_BF_COMPOSITOR']: defs.append("WITH_COMPOSITOR") +if env['WITH_BF_PYTHON_SECURITY']: + defs.append("WITH_PYTHON_SECURITY") + env.BlenderLib ( 'bf_windowmanager', sources, Split(incs), defines=defs, libtype=['core'], priority=[5] ) diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index c372e2d1ce6..f9e93118033 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -541,7 +541,7 @@ int wm_homefile_read(bContext *C, ReportList *UNUSED(reports), short from_memory success = BKE_read_file_from_memory(C, datatoc_startup_blend, datatoc_startup_blend_size, NULL); if (wmbase.first == NULL) wm_clear_default_size(C); -#ifdef WITH_PYTHON_SECURITY /* not default */ +#ifdef WITH_PYTHON_SECURITY /* use alternative setting for security nuts * otherwise we'd need to patch the binary blob - startup.blend.c */ U.flag |= USER_SCRIPT_AUTOEXEC_DISABLE; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 423ddfcc568..d832e84d7f0 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1916,19 +1916,26 @@ static void WM_OT_read_factory_settings(wmOperatorType *ot) /* *************** open file **************** */ -static void open_set_load_ui(wmOperator *op) +static void open_set_load_ui(wmOperator *op, bool use_prefs) { - if (!RNA_struct_property_is_set(op->ptr, "load_ui")) - RNA_boolean_set(op->ptr, "load_ui", !(U.flag & USER_FILENOUI)); + PropertyRNA *prop = RNA_struct_find_property(op->ptr, "load_ui"); + if (!RNA_property_is_set(op->ptr, prop)) { + RNA_property_boolean_set(op->ptr, prop, use_prefs ? + (U.flag & USER_FILENOUI) == 0 : + (G.fileflags |= G_FILE_NO_UI) == 0); + } } -static void open_set_use_scripts(wmOperator *op) +static void open_set_use_scripts(wmOperator *op, bool use_prefs) { - if (!RNA_struct_property_is_set(op->ptr, "use_scripts")) { + PropertyRNA *prop = RNA_struct_find_property(op->ptr, "use_scripts"); + if (!RNA_property_is_set(op->ptr, prop)) { /* use G_SCRIPT_AUTOEXEC rather than the userpref because this means if * the flag has been disabled from the command line, then opening * from the menu wont enable this setting. */ - RNA_boolean_set(op->ptr, "use_scripts", (G.f & G_SCRIPT_AUTOEXEC)); + RNA_property_boolean_set(op->ptr, prop, use_prefs ? + (U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0 : + (G.f & G_SCRIPT_AUTOEXEC) != 0); } } @@ -1951,8 +1958,8 @@ static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *U } RNA_string_set(op->ptr, "filepath", openname); - open_set_load_ui(op); - open_set_use_scripts(op); + open_set_load_ui(op, true); + open_set_use_scripts(op, true); WM_event_add_fileselect(C, op); @@ -1964,8 +1971,10 @@ static int wm_open_mainfile_exec(bContext *C, wmOperator *op) char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); - open_set_load_ui(op); - open_set_use_scripts(op); + + /* re-use last loaded setting so we can reload a file without changing */ + open_set_load_ui(op, false); + open_set_use_scripts(op, false); if (RNA_boolean_get(op->ptr, "load_ui")) G.fileflags &= ~G_FILE_NO_UI; |