[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27165] trunk/blender/source/blender: fixes for auto script execution, changing the user preference also updates the global flag.

Campbell Barton ideasman42 at gmail.com
Sat Feb 27 13:34:49 CET 2010


Revision: 27165
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27165
Author:   campbellbarton
Date:     2010-02-27 13:34:49 +0100 (Sat, 27 Feb 2010)

Log Message:
-----------
fixes for auto script execution, changing the user preference also updates the global flag.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/blender.c
    trunk/blender/source/blender/makesrna/intern/rna_userdef.c
    trunk/blender/source/blender/windowmanager/intern/wm_files.c
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: trunk/blender/source/blender/blenkernel/intern/blender.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/blender.c	2010-02-27 12:01:10 UTC (rev 27164)
+++ trunk/blender/source/blender/blenkernel/intern/blender.c	2010-02-27 12:34:49 UTC (rev 27165)
@@ -291,8 +291,6 @@
 	if (G.f & G_SWAP_EXCHANGE) bfd->globalf |= G_SWAP_EXCHANGE;
 	else bfd->globalf &= ~G_SWAP_EXCHANGE;
 
-	if ((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE)) bfd->globalf &= ~G_SCRIPT_AUTOEXEC;
-
 	G.f= bfd->globalf;
 
 	if (!G.background) {

Modified: trunk/blender/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2010-02-27 12:01:10 UTC (rev 27164)
+++ trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2010-02-27 12:34:49 UTC (rev 27165)
@@ -47,6 +47,7 @@
 #include "BKE_depsgraph.h"
 #include "DNA_object_types.h"
 #include "GPU_draw.h"
+#include "BKE_global.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -55,6 +56,13 @@
 	WM_main_add_notifier(NC_WINDOW, NULL);
 }
 
+static void rna_userdef_script_autoexec_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+	UserDef *userdef = (UserDef*)ptr->data;
+	if (userdef->flag & USER_SCRIPT_AUTOEXEC_DISABLE)	G.f &= ~G_SCRIPT_AUTOEXEC;
+	else												G.f |=  G_SCRIPT_AUTOEXEC;
+}
+
 static void rna_userdef_mipmap_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
 	GPU_set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
@@ -2346,8 +2354,9 @@
 	RNA_def_property_ui_text(prop, "Enable All Codecs", "Enables automatic saving of preview images in the .blend file (Windows only)");
 
 	prop= RNA_def_property(srna, "auto_execute_scripts", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_SCRIPT_AUTOEXEC_DISABLE);
+	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_SCRIPT_AUTOEXEC_DISABLE);
 	RNA_def_property_ui_text(prop, "Auto Run Python Scripts", "Allow any .blend file to run scripts automatically (unsafe with blend files from an untrusted source)");
+	RNA_def_property_update(prop, 0, "rna_userdef_script_autoexec_update");
 
 	prop= RNA_def_property(srna, "prefetch_frames", PROP_INT, PROP_NONE);
 	RNA_def_property_int_sdna(prop, NULL, "prefetchframes");

Modified: trunk/blender/source/blender/windowmanager/intern/wm_files.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_files.c	2010-02-27 12:01:10 UTC (rev 27164)
+++ trunk/blender/source/blender/windowmanager/intern/wm_files.c	2010-02-27 12:34:49 UTC (rev 27165)
@@ -241,6 +241,10 @@
 	UI_init_userdef();
 	MEM_CacheLimiter_set_maximum(U.memcachelimit * 1024 * 1024);
 	sound_init(CTX_data_main(C));
+
+	/* set the python auto-execute setting from user prefs */
+	if (U.flag & USER_SCRIPT_AUTOEXEC_DISABLE)	G.f &= ~G_SCRIPT_AUTOEXEC;
+	else										G.f |=  G_SCRIPT_AUTOEXEC;
 }
 
 void WM_read_file(bContext *C, char *name, ReportList *reports)

Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2010-02-27 12:01:10 UTC (rev 27164)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2010-02-27 12:34:49 UTC (rev 27165)
@@ -1329,7 +1329,7 @@
 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));
+		RNA_boolean_set(op->ptr, "use_scripts", !(U.flag & USER_SCRIPT_AUTOEXEC_DISABLE));
 }
 
 static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)





More information about the Bf-blender-cvs mailing list