diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-03-15 11:04:11 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-03-15 11:04:11 +0300 |
commit | b65a56ccb52e656cbdc9033180c26fb56d5c5ffd (patch) | |
tree | 7f21f7388fc39c19f3eff4333f50c5b72f2becba /source | |
parent | b332a27429f40ef51deeff8de163d2280edb2314 (diff) |
fix [#26494] Auto run Python scripts option in User Preferences problem
- opening a file with blender by passing it as an argument would and loading it once in blender left script auto execute flag in a different state.
- command line args --enable/disable-autoexec were being overridden by the user prefs.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_global.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blender.c | 11 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 13 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 8 | ||||
-rw-r--r-- | source/creator/creator.c | 4 |
5 files changed, 24 insertions, 13 deletions
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index d83e0e5bc4c..0360acbea32 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -111,6 +111,7 @@ typedef struct Global { #define G_DEBUG (1 << 12) #define G_SCRIPT_AUTOEXEC (1 << 13) +#define G_SCRIPT_OVERRIDE_PREF (1 << 14) /* when this flag is set ignore the userprefs */ /* #define G_NOFROZEN (1 << 17) also removed */ #define G_GREASEPENCIL (1 << 17) diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 3c996006f5d..9fb36d8f6b7 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -271,12 +271,11 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename } /* special cases, override loaded flags: */ - if (G.f & G_DEBUG) bfd->globalf |= G_DEBUG; - else bfd->globalf &= ~G_DEBUG; - if (G.f & G_SWAP_EXCHANGE) bfd->globalf |= G_SWAP_EXCHANGE; - else bfd->globalf &= ~G_SWAP_EXCHANGE; - if (G.f & G_SCRIPT_AUTOEXEC) bfd->globalf |= G_SCRIPT_AUTOEXEC; - else bfd->globalf &= ~G_SCRIPT_AUTOEXEC; + if(G.f != bfd->globalf) { + const int flags_keep= (G_DEBUG | G_SWAP_EXCHANGE | G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF); + bfd->globalf= (bfd->globalf & ~flags_keep) | (G.f & flags_keep); + } + G.f= bfd->globalf; diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 48528574f7e..ebf3e856241 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -267,8 +267,11 @@ static void wm_init_userdef(bContext *C) else G.fileflags &= ~G_FILE_NO_UI; /* set the python auto-execute setting from user prefs */ - /* disabled by default, unless explicitly enabled in the command line */ - if ((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0) G.f |= G_SCRIPT_AUTOEXEC; + /* enabled by default, unless explicitly enabled in the command line which overrides */ + if((G.f & G_SCRIPT_OVERRIDE_PREF) == 0) { + if ((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0) G.f |= G_SCRIPT_AUTOEXEC; + else G.f &= ~G_SCRIPT_AUTOEXEC; + } if(U.tempdir[0]) BLI_where_is_temp(btempdir, FILE_MAX, 1); } @@ -300,8 +303,10 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports) /* this flag is initialized by the operator but overwritten on read. * need to re-enable it here else drivers + registered scripts wont work. */ - if(G_f & G_SCRIPT_AUTOEXEC) G.f |= G_SCRIPT_AUTOEXEC; - else G.f &= ~G_SCRIPT_AUTOEXEC; + if(G.f != G_f) { + const int flags_keep= (G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF); + G.f= (G.f & ~flags_keep) | (G_f & flags_keep); + } /* match the read WM with current WM */ wm_window_match_do(C, &wmbase); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 27276e2aaac..7aa56ed322b 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1391,8 +1391,12 @@ static void open_set_load_ui(wmOperator *op) static void open_set_use_scripts(wmOperator *op) { - if(!RNA_property_is_set(op->ptr, "use_scripts")) - RNA_boolean_set(op->ptr, "use_scripts", !(U.flag & USER_SCRIPT_AUTOEXEC_DISABLE)); + if(!RNA_property_is_set(op->ptr, "use_scripts")) { + /* use G_SCRIPT_AUTOEXEC rather then 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)); + } } static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) diff --git a/source/creator/creator.c b/source/creator/creator.c index f64deb7414a..5b5c0b77022 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -356,12 +356,14 @@ static int end_arguments(int UNUSED(argc), const char **UNUSED(argv), void *UNUS static int enable_python(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { G.f |= G_SCRIPT_AUTOEXEC; + G.f |= G_SCRIPT_OVERRIDE_PREF; return 0; } -static int disable_python(int UNUSED(argc), const const char **UNUSED(argv), void *UNUSED(data)) +static int disable_python(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { G.f &= ~G_SCRIPT_AUTOEXEC; + G.f |= G_SCRIPT_OVERRIDE_PREF; return 0; } |