[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35557] trunk/blender/source: fix [#26494] Auto run Python scripts option in User Preferences problem
Campbell Barton
ideasman42 at gmail.com
Tue Mar 15 09:04:12 CET 2011
Revision: 35557
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35557
Author: campbellbarton
Date: 2011-03-15 08:04:11 +0000 (Tue, 15 Mar 2011)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_global.h
trunk/blender/source/blender/blenkernel/intern/blender.c
trunk/blender/source/blender/windowmanager/intern/wm_files.c
trunk/blender/source/blender/windowmanager/intern/wm_operators.c
trunk/blender/source/creator/creator.c
Modified: trunk/blender/source/blender/blenkernel/BKE_global.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_global.h 2011-03-15 05:00:10 UTC (rev 35556)
+++ trunk/blender/source/blender/blenkernel/BKE_global.h 2011-03-15 08:04:11 UTC (rev 35557)
@@ -111,6 +111,7 @@
#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)
Modified: trunk/blender/source/blender/blenkernel/intern/blender.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/blender.c 2011-03-15 05:00:10 UTC (rev 35556)
+++ trunk/blender/source/blender/blenkernel/intern/blender.c 2011-03-15 08:04:11 UTC (rev 35557)
@@ -271,13 +271,12 @@
}
/* 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;
if (!G.background) {
Modified: trunk/blender/source/blender/windowmanager/intern/wm_files.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_files.c 2011-03-15 05:00:10 UTC (rev 35556)
+++ trunk/blender/source/blender/windowmanager/intern/wm_files.c 2011-03-15 08:04:11 UTC (rev 35557)
@@ -267,8 +267,11 @@
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 @@
/* 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);
Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2011-03-15 05:00:10 UTC (rev 35556)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2011-03-15 08:04:11 UTC (rev 35557)
@@ -1391,8 +1391,12 @@
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))
Modified: trunk/blender/source/creator/creator.c
===================================================================
--- trunk/blender/source/creator/creator.c 2011-03-15 05:00:10 UTC (rev 35556)
+++ trunk/blender/source/creator/creator.c 2011-03-15 08:04:11 UTC (rev 35557)
@@ -356,12 +356,14 @@
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;
}
More information about the Bf-blender-cvs
mailing list