forked from bartvdbraak/blender
option to set the blend file as from a 'Trusted Source' on load.
This commit is contained in:
parent
5be3bf73be
commit
4e931482f4
@ -30,6 +30,7 @@
|
||||
|
||||
#include "BPY_extern.h"
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_global.h"
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
@ -165,6 +166,11 @@ float BPY_pydriver_eval (ChannelDriver *driver)
|
||||
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 */
|
||||
|
@ -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 @@ void BPY_load_user_modules(bContext *C)
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1326,10 +1326,17 @@ static void open_set_load_ui(wmOperator *op)
|
||||
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 @@ static int wm_open_mainfile_exec(bContext *C, wmOperator *op)
|
||||
|
||||
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 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
|
||||
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 *************** */
|
||||
|
Loading…
Reference in New Issue
Block a user