From 447e9a4cd5d385e8724b7f92c952d66bd35a2c34 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 18 Jun 2013 18:11:52 +0000 Subject: add option to enable auto-execute scripts, but exclude certain directories. --- release/scripts/startup/bl_ui/space_userpref.py | 23 ++++- source/blender/blenkernel/BKE_autoexec.h | 31 ++++++ source/blender/blenkernel/CMakeLists.txt | 2 + source/blender/blenkernel/intern/autoexec.c | 69 +++++++++++++ source/blender/blenkernel/intern/blender.c | 2 + source/blender/blenloader/intern/readfile.c | 1 + source/blender/blenloader/intern/writefile.c | 5 + source/blender/editors/space_file/filesel.c | 1 + source/blender/makesdna/DNA_userdef_types.h | 14 ++- source/blender/makesrna/intern/rna_userdef.c | 76 +++++++++++++- source/blender/windowmanager/WM_api.h | 1 + source/blender/windowmanager/intern/wm_files.c | 16 +++ source/blender/windowmanager/intern/wm_operators.c | 111 ++++++++++++++++++++- source/creator/creator.c | 1 + 14 files changed, 344 insertions(+), 9 deletions(-) create mode 100644 source/blender/blenkernel/BKE_autoexec.h create mode 100644 source/blender/blenkernel/intern/autoexec.c diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index ef4e5468194..a497ecfb927 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -867,8 +867,21 @@ class USERPREF_PT_file(Panel): colsplit = col.split(percentage=0.95) sub = colsplit.column() - sub.label(text="Author:") - sub.prop(system, "author", text="") + + row = sub.split(percentage=0.3) + row.label(text="Auto Execution:") + row.prop(system, "use_scripts_auto_execute") + + if system.use_scripts_auto_execute: + box = sub.box() + row = box.row() + row.label(text="Excluded Paths:") + row.operator("wm.userpref_autoexec_path_add", text="", icon='ZOOMIN', emboss=False) + for i, path_cmp in enumerate(userpref.autoexec_paths): + row = box.row() + row.prop(path_cmp, "path", text="") + row.prop(path_cmp, "use_glob", text="", icon='FILTER') + row.operator("wm.userpref_autoexec_path_remove", text="", icon='X', emboss=False).index = i col = split.column() col.label(text="Save & Load:") @@ -896,10 +909,12 @@ class USERPREF_PT_file(Panel): col.separator() - col.label(text="Scripts:") - col.prop(system, "use_scripts_auto_execute") + col.label(text="Text Editor:") col.prop(system, "use_tabs_as_spaces") + col.label(text="Author:") + col.prop(system, "author", text="") + from bl_ui.space_userpref_keymap import InputKeyMapPanel diff --git a/source/blender/blenkernel/BKE_autoexec.h b/source/blender/blenkernel/BKE_autoexec.h new file mode 100644 index 00000000000..7dc1e76ed5c --- /dev/null +++ b/source/blender/blenkernel/BKE_autoexec.h @@ -0,0 +1,31 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Blender Foundation 2013 + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef __BKE_AUTOEXEC_H__ +#define __BKE_AUTOEXEC_H__ + +/** \file BKE_autoexec.h + * \ingroup bke + */ + +bool BKE_autoexec_match(const char *path); + +#endif /* __BKE_AUTOEXEC_H__ */ diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 3864fe3b350..7e1355b5421 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -63,6 +63,7 @@ set(SRC intern/anim.c intern/anim_sys.c intern/armature.c + intern/autoexec.c intern/blender.c intern/bmfont.c intern/boids.c @@ -163,6 +164,7 @@ set(SRC BKE_anim.h BKE_animsys.h BKE_armature.h + BKE_autoexec.h BKE_blender.h BKE_bmesh.h BKE_bmfont.h diff --git a/source/blender/blenkernel/intern/autoexec.c b/source/blender/blenkernel/intern/autoexec.c new file mode 100644 index 00000000000..48bebd34179 --- /dev/null +++ b/source/blender/blenkernel/intern/autoexec.c @@ -0,0 +1,69 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Blender Foundation 2013 + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/armature.c + * \ingroup bke + * + * Currently just checks if a blend file can be trusted to autoexec, + * may add signing here later. + */ + +#include +#include + +#include "DNA_userdef_types.h" + +#include "BLI_utildefines.h" +#include "BLI_fnmatch.h" +#include "BLI_path_util.h" + +#include "BKE_autoexec.h" /* own include */ + +/** + * \param path The path to check against. + * \return Success + */ +bool BKE_autoexec_match(const char *path) +{ + bPathCompare *path_cmp; + +#ifdef WIN32 + const int fnmatch_flags = FNM_CASEFOLD; +#else + const int fnmatch_flags = 0; +#endif + + BLI_assert((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0); + + for (path_cmp = U.autoexec_paths.first; path_cmp; path_cmp = path_cmp->next) { + if ((path_cmp->flag & USER_PATHCMP_GLOB)) { + if (fnmatch(path_cmp->path, path, fnmatch_flags) == 0) { + return true; + } + } + else if (BLI_path_ncmp(path_cmp->path, path, strlen(path_cmp->path)) == 0) { + return true; + } + } + + return false; +} diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 87a8def52bf..1e7aba6d25b 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -416,6 +416,8 @@ void BKE_userdef_free(void) MEM_freeN(addon); } + BLI_freelistN(&U.autoexec_paths); + BLI_freelistN(&U.uistyles); BLI_freelistN(&U.uifonts); BLI_freelistN(&U.themes); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index d44e3fd4948..07ed2f18111 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -9605,6 +9605,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) link_list(fd, &user->themes); link_list(fd, &user->user_keymaps); link_list(fd, &user->addons); + link_list(fd, &user->autoexec_paths); for (keymap=user->user_keymaps.first; keymap; keymap=keymap->next) { keymap->modal_items= NULL; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index d8bf1a5e4c4..9b6699f3f21 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -860,6 +860,7 @@ static void write_userdef(WriteData *wd) wmKeyMapItem *kmi; wmKeyMapDiffItem *kmdi; bAddon *bext; + bPathCompare *path_cmp; uiStyle *style; writestruct(wd, USER, "UserDef", 1, &U); @@ -888,6 +889,10 @@ static void write_userdef(WriteData *wd) IDP_WriteProperty(bext->prop, wd); } } + + for (path_cmp = U.autoexec_paths.first; path_cmp; path_cmp = path_cmp->next) { + writestruct(wd, DATA, "bPathCompare", 1, path_cmp); + } for (style= U.uistyles.first; style; style= style->next) { writestruct(wd, DATA, "uiStyle", 1, style); diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 25d865d857b..59801796f8c 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -609,6 +609,7 @@ void file_change_dir(bContext *C, int checkdir) folderlist_pushdir(sfile->folders_prev, sfile->params->dir); + file_draw_check_cb(C, NULL, NULL); } } diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index a846ac697f0..e0c5cd5608e 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -360,6 +360,12 @@ typedef struct bAddon { IDProperty *prop; /* User-Defined Properties on this Addon (for storing preferences) */ } bAddon; +typedef struct bPathCompare { + struct bPathCompare *next, *prev; + char path[768]; /* FILE_MAXDIR */ + char flag, pad[7]; +} bPathCompare; + typedef struct SolidLight { int flag, pad; float col[4], spec[4], vec[4]; @@ -412,6 +418,7 @@ typedef struct UserDef { struct ListBase keymaps DNA_DEPRECATED; /* deprecated in favor of user_keymaps */ struct ListBase user_keymaps; struct ListBase addons; + struct ListBase autoexec_paths; char keyconfigstr[64]; short undosteps; @@ -522,7 +529,12 @@ typedef enum eUserPref_Flag { USER_TXT_TABSTOSPACES_DISABLE = (1 << 25), USER_TOOLTIPS_PYTHON = (1 << 26), } eUserPref_Flag; - + +/* flag */ +typedef enum ePathCompare_Flag { + USER_PATHCMP_GLOB = (1 << 0), +} ePathCompare_Flag; + /* helper macro for checking frame clamping */ #define FRAMENUMBER_MIN_CLAMP(cfra) { \ if ((U.flag & USER_NONEGFRAMES) && (cfra < 0)) \ diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 347c57f9044..f34366a23c7 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -339,9 +339,9 @@ static bAddon *rna_userdef_addon_new(void) return bext; } -static void rna_userdef_addon_remove(ReportList *reports, PointerRNA *bext_ptr) +static void rna_userdef_addon_remove(ReportList *reports, PointerRNA *path_cmp_ptr) { - bAddon *bext = bext_ptr->data; + bAddon *bext = path_cmp_ptr->data; if (BLI_findindex(&U.addons, bext) == -1) { BKE_report(reports, RPT_ERROR, "Addon is no longer valid"); return; @@ -353,7 +353,26 @@ static void rna_userdef_addon_remove(ReportList *reports, PointerRNA *bext_ptr) } BLI_freelinkN(&U.addons, bext); - RNA_POINTER_INVALIDATE(bext_ptr); + RNA_POINTER_INVALIDATE(path_cmp_ptr); +} + +static bPathCompare *rna_userdef_pathcompare_new(void) +{ + bPathCompare *path_cmp = MEM_callocN(sizeof(bPathCompare), "bPathCompare"); + BLI_addtail(&U.autoexec_paths, path_cmp); + return path_cmp; +} + +static void rna_userdef_pathcompare_remove(ReportList *reports, PointerRNA *path_cmp_ptr) +{ + bPathCompare *path_cmp = path_cmp_ptr->data; + if (BLI_findindex(&U.autoexec_paths, path_cmp) == -1) { + BKE_report(reports, RPT_ERROR, "Addon is no longer valid"); + return; + } + + BLI_freelinkN(&U.autoexec_paths, path_cmp); + RNA_POINTER_INVALIDATE(path_cmp_ptr); } static void rna_userdef_temp_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) @@ -2733,6 +2752,25 @@ static void rna_def_userdef_addon(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, "rna_Addon_preferences_get", NULL, NULL, NULL); } +static void rna_def_userdef_pathcompare(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "PathCompare", NULL); + RNA_def_struct_sdna(srna, "bPathCompare"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); + RNA_def_struct_ui_text(srna, "Path Compare", "Match paths against this value"); + + prop = RNA_def_property(srna, "path", PROP_STRING, PROP_DIRPATH); + RNA_def_property_ui_text(prop, "Path", ""); + RNA_def_struct_name_property(srna, prop); + + prop = RNA_def_property(srna, "use_glob", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_PATHCMP_GLOB); + RNA_def_property_ui_text(prop, "Use Wildcard", "Enable wildcard globbing"); +} + static void rna_def_userdef_addon_pref(BlenderRNA *brna) { StructRNA *srna; @@ -4027,6 +4065,32 @@ static void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cpro RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } +static void rna_def_userdef_autoexec_path_collection(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "PathCompareCollection"); + srna = RNA_def_struct(brna, "PathCompareCollection", NULL); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); + RNA_def_struct_ui_text(srna, "Paths Compare", "Collection of paths"); + + func = RNA_def_function(srna, "new", "rna_userdef_pathcompare_new"); + RNA_def_function_flag(func, FUNC_NO_SELF); + RNA_def_function_ui_description(func, "Add a new addon"); + /* return type */ + parm = RNA_def_pointer(func, "pathcmp", "PathCompare", "", ""); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_userdef_pathcompare_remove"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove path"); + parm = RNA_def_pointer(func, "pathcmp", "PathCompare", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); +} + void RNA_def_userdef(BlenderRNA *brna) { StructRNA *srna; @@ -4074,6 +4138,11 @@ void RNA_def_userdef(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Addon", ""); rna_def_userdef_addon_collection(brna, prop); + prop = RNA_def_property(srna, "autoexec_paths", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "autoexec_paths", NULL); + RNA_def_property_struct_type(prop, "PathCompare"); + RNA_def_property_ui_text(prop, "Autoexec Paths", ""); + rna_def_userdef_autoexec_path_collection(brna, prop); /* nested structs */ prop = RNA_def_property(srna, "view", PROP_POINTER, PROP_NONE); @@ -4113,6 +4182,7 @@ void RNA_def_userdef(BlenderRNA *brna) rna_def_userdef_system(brna); rna_def_userdef_addon(brna); rna_def_userdef_addon_pref(brna); + rna_def_userdef_pathcompare(brna); } diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 01ddbd3995b..72b54e2f1f7 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -112,6 +112,7 @@ bool WM_is_draw_triple(struct wmWindow *win); /* files */ +void WM_file_autoexec_init(const char *filepath); void WM_file_read(struct bContext *C, const char *filepath, struct ReportList *reports); void WM_autosave_init(struct wmWindowManager *wm); void WM_recover_last_session(struct bContext *C, struct ReportList *reports); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index b6aecf120cc..f4b50667b2f 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -70,6 +70,7 @@ #include "DNA_screen_types.h" #include "DNA_windowmanager_types.h" +#include "BKE_autoexec.h" #include "BKE_blender.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -364,6 +365,21 @@ static int wm_read_exotic(Scene *UNUSED(scene), const char *name) return retval; } +void WM_file_autoexec_init(const char *filepath) +{ + if (G.f & G_SCRIPT_OVERRIDE_PREF) { + return; + } + + if (G.f & G_SCRIPT_AUTOEXEC) { + char path[FILE_MAX]; + BLI_split_dir_part(filepath, path, sizeof(path)); + if (BKE_autoexec_match(path)) { + G.f &= ~G_SCRIPT_AUTOEXEC; + } + } +} + void WM_file_read(bContext *C, const char *filepath, ReportList *reports) { int retval; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index d729e15a43d..cd0042731c1 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -60,6 +60,7 @@ #include "BLO_readfile.h" +#include "BKE_autoexec.h" #include "BKE_blender.h" #include "BKE_brush.h" #include "BKE_context.h" @@ -1868,6 +1869,47 @@ static void WM_OT_save_homefile(wmOperatorType *ot) ot->poll = WM_operator_winactive; } +static int wm_userpref_autoexec_add_exec(bContext *UNUSED(C), wmOperator *UNUSED(op)) +{ + bPathCompare *path_cmp = MEM_callocN(sizeof(bPathCompare), "bPathCompare"); + BLI_addtail(&U.autoexec_paths, path_cmp); + return OPERATOR_FINISHED; +} + +static void WM_OT_userpref_autoexec_path_add(wmOperatorType *ot) +{ + ot->name = "Add Autoexec Path"; + ot->idname = "WM_OT_userpref_autoexec_path_add"; + + ot->exec = wm_userpref_autoexec_add_exec; + ot->poll = WM_operator_winactive; + + ot->flag = OPTYPE_INTERNAL; +} + +static int wm_userpref_autoexec_remove_exec(bContext *UNUSED(C), wmOperator *op) +{ + const int index = RNA_int_get(op->ptr, "index"); + bPathCompare *path_cmp = BLI_findlink(&U.autoexec_paths, index); + if (path_cmp) { + BLI_freelinkN(&U.autoexec_paths, path_cmp); + } + return OPERATOR_FINISHED; +} + +static void WM_OT_userpref_autoexec_path_remove(wmOperatorType *ot) +{ + ot->name = "Remove Autoexec Path"; + ot->idname = "WM_OT_userpref_autoexec_path_remove"; + + ot->exec = wm_userpref_autoexec_remove_exec; + ot->poll = WM_operator_winactive; + + ot->flag = OPTYPE_INTERNAL; + + RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000); +} + static void WM_OT_save_userpref(wmOperatorType *ot) { ot->name = "Save User Settings"; @@ -1916,6 +1958,12 @@ static void WM_OT_read_factory_settings(wmOperatorType *ot) /* *************** open file **************** */ +/* currently fits in a pointer */ +struct FileRuntime { + bool is_untrusted; +}; + + static void open_set_load_ui(wmOperator *op, bool use_prefs) { PropertyRNA *prop = RNA_struct_find_property(op->ptr, "load_ui"); @@ -1960,6 +2008,7 @@ 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, true); open_set_use_scripts(op, true); + op->customdata = NULL; WM_event_add_fileselect(C, op); @@ -1990,11 +2039,65 @@ static int wm_open_mainfile_exec(bContext *C, wmOperator *op) /* do it before for now, but is this correct with multiple windows? */ WM_event_add_notifier(C, NC_WINDOW, NULL); + /* autoexec is already set correctly for invoke() for exec() though we need to initialize */ + if (!RNA_struct_property_is_set(op->ptr, "use_scripts")) { + WM_file_autoexec_init(path); + } WM_file_read(C, path, op->reports); - + return OPERATOR_FINISHED; } +static bool wm_open_mainfile_check(bContext *UNUSED(C), wmOperator *op) +{ + struct FileRuntime *file_info = (struct FileRuntime *)&op->customdata; + PropertyRNA *prop = RNA_struct_find_property(op->ptr, "use_scripts"); + bool is_untrusted = false; + char path[FILE_MAX]; + char *lslash; + + RNA_string_get(op->ptr, "filepath", path); + + /* get the dir */ + lslash = (char *)BLI_last_slash(path); + if (lslash) *(lslash + 1) = '\0'; + + if ((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0) { + if (BKE_autoexec_match(path) == true) { + RNA_property_boolean_set(op->ptr, prop, false); + is_untrusted = true; + } + } + + if (file_info) { + file_info->is_untrusted = is_untrusted; + } + + return is_untrusted; +} + +static void wm_open_mainfile_ui(bContext *UNUSED(C), wmOperator *op) +{ + struct FileRuntime *file_info = (struct FileRuntime *)&op->customdata; + uiLayout *layout = op->layout; + uiLayout *col = op->layout; + const char *autoexec_text = NULL; + + uiItemR(layout, op->ptr, "load_ui", 0, NULL, ICON_NONE); + + col = uiLayoutColumn(layout, false); + if (file_info->is_untrusted) { + autoexec_text = "Trusted Source [Untrusted Path]"; + uiLayoutSetActive(col, false); + uiLayoutSetEnabled(col, false); + } + else { + autoexec_text = "Trusted Source"; + } + + uiItemR(col, op->ptr, "use_scripts", 0, autoexec_text, ICON_NONE); +} + static void WM_OT_open_mainfile(wmOperatorType *ot) { ot->name = "Open Blender File"; @@ -2003,6 +2106,8 @@ static void WM_OT_open_mainfile(wmOperatorType *ot) ot->invoke = wm_open_mainfile_invoke; ot->exec = wm_open_mainfile_exec; + ot->check = wm_open_mainfile_check; + ot->ui = wm_open_mainfile_ui; /* ommit window poll so this can work in background mode */ WM_operator_properties_filesel(ot, FOLDERFILE | BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, @@ -2233,6 +2338,7 @@ void WM_recover_last_session(bContext *C, ReportList *reports) WM_event_add_notifier(C, NC_WINDOW, NULL); /* load file */ + WM_file_autoexec_init(filename); WM_file_read(C, filename, reports); G.fileflags &= ~G_FILE_RECOVER; @@ -2279,6 +2385,7 @@ static int wm_recover_auto_save_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_WINDOW, NULL); /* load file */ + WM_file_autoexec_init(path); WM_file_read(C, path, op->reports); G.fileflags &= ~G_FILE_RECOVER; @@ -4044,6 +4151,8 @@ void wm_operatortype_init(void) WM_operatortype_append(WM_OT_read_factory_settings); WM_operatortype_append(WM_OT_save_homefile); WM_operatortype_append(WM_OT_save_userpref); + WM_operatortype_append(WM_OT_userpref_autoexec_path_add); + WM_operatortype_append(WM_OT_userpref_autoexec_path_remove); WM_operatortype_append(WM_OT_window_fullscreen_toggle); WM_operatortype_append(WM_OT_quit_blender); WM_operatortype_append(WM_OT_open_mainfile); diff --git a/source/creator/creator.c b/source/creator/creator.c index 302467c6b3d..817bc4fcf60 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -1262,6 +1262,7 @@ static int load_file(int UNUSED(argc), const char **argv, void *data) * a file - this should do everything a 'load file' does */ ReportList reports; BKE_reports_init(&reports, RPT_PRINT); + WM_file_autoexec_init(filename); WM_file_read(C, filename, &reports); BKE_reports_clear(&reports); } -- cgit v1.2.3