[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27160] trunk/blender/source/blender: option to set the blend file as from a 'Trusted Source' on load.
Campbell Barton
ideasman42 at gmail.com
Sat Feb 27 02:27:23 CET 2010
Revision: 27160
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27160
Author: campbellbarton
Date: 2010-02-27 02:27:22 +0100 (Sat, 27 Feb 2010)
Log Message:
-----------
option to set the blend file as from a 'Trusted Source' on load.
Modified Paths:
--------------
trunk/blender/source/blender/python/intern/bpy_driver.c
trunk/blender/source/blender/python/intern/bpy_interface.c
trunk/blender/source/blender/windowmanager/intern/wm_operators.c
Modified: trunk/blender/source/blender/python/intern/bpy_driver.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_driver.c 2010-02-26 23:56:16 UTC (rev 27159)
+++ trunk/blender/source/blender/python/intern/bpy_driver.c 2010-02-27 01:27:22 UTC (rev 27160)
@@ -30,6 +30,7 @@
#include "BPY_extern.h"
#include "BKE_fcurve.h"
+#include "BKE_global.h"
#include <Python.h>
@@ -165,6 +166,11 @@
if ((expr == NULL) || (expr[0]=='\0'))
return result;
+ if(!(G.fileflags & G_DOSCRIPTLINKS)) {
+ printf("skipping driver '%s', automatic scripts are disabled\n", driver->expression);
+ return result;
+ }
+
gilstate = PyGILState_Ensure();
/* init global dictionary for py-driver evaluation settings */
Modified: trunk/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_interface.c 2010-02-26 23:56:16 UTC (rev 27159)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c 2010-02-27 01:27:22 UTC (rev 27160)
@@ -62,6 +62,7 @@
#include "BKE_text.h"
#include "BKE_context.h"
#include "BKE_main.h"
+#include "BKE_global.h" /* only for script checking */
#include "BPY_extern.h"
@@ -630,14 +631,19 @@
for(text=CTX_data_main(C)->text.first; text; text= text->id.next) {
if(text->flags & TXT_ISSCRIPT && BLI_testextensie(text->id.name+2, ".py")) {
- PyObject *module= bpy_text_import(text);
-
- if (module==NULL) {
- PyErr_Print();
- PyErr_Clear();
+ if(!(G.fileflags & G_DOSCRIPTLINKS)) {
+ printf("scripts disabled for \"%s\", skipping '%s'\n", bmain->name, text->id.name+2);
}
else {
- Py_DECREF(module);
+ PyObject *module= bpy_text_import(text);
+
+ if (module==NULL) {
+ PyErr_Print();
+ PyErr_Clear();
+ }
+ else {
+ Py_DECREF(module);
+ }
}
}
}
Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2010-02-26 23:56:16 UTC (rev 27159)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2010-02-27 01:27:22 UTC (rev 27160)
@@ -1326,10 +1326,17 @@
RNA_boolean_set(op->ptr, "load_ui", !(U.flag & USER_FILENOUI));
}
+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_DONT_DOSCRIPTLINKS));
+}
+
static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
RNA_string_set(op->ptr, "path", G.sce);
open_set_load_ui(op);
+ open_set_use_scripts(op);
WM_event_add_fileselect(C, op);
@@ -1342,11 +1349,17 @@
RNA_string_get(op->ptr, "path", path);
open_set_load_ui(op);
+ open_set_use_scripts(op);
if(RNA_boolean_get(op->ptr, "load_ui"))
G.fileflags &= ~G_FILE_NO_UI;
else
G.fileflags |= G_FILE_NO_UI;
+
+ if(RNA_boolean_get(op->ptr, "use_scripts"))
+ G.fileflags |= G_DOSCRIPTLINKS;
+ else
+ G.fileflags &= ~G_DOSCRIPTLINKS;
// XXX wm in context is not set correctly after WM_read_file -> crash
// do it before for now, but is this correct with multiple windows?
@@ -1370,6 +1383,7 @@
WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_OPENFILE);
RNA_def_boolean(ot->srna, "load_ui", 1, "Load UI", "Load user interface setup in the .blend file");
+ RNA_def_boolean(ot->srna, "use_scripts", 1, "Trusted Source", "Allow blend file execute scripts automatically, default available from system preferences");
}
/* **************** link/append *************** */
More information about the Bf-blender-cvs
mailing list