fixes for auto script execution, changing the user preference also updates the global flag.
This commit is contained in:
@@ -291,8 +291,6 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename)
|
||||
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) {
|
||||
|
||||
@@ -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 @@ static void rna_userdef_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
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 @@ static void rna_def_userdef_system(BlenderRNA *brna)
|
||||
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");
|
||||
|
||||
@@ -241,6 +241,10 @@ static void wm_init_userdef(bContext *C)
|
||||
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)
|
||||
|
||||
@@ -1329,7 +1329,7 @@ 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));
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user