diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c index 6ecff4181384..beabdba71325 100644 --- a/source/blender/editors/space_logic/logic_ops.c +++ b/source/blender/editors/space_logic/logic_ops.c @@ -47,6 +47,8 @@ #include "BKE_main.h" #include "BKE_sca.h" #include "BKE_python_component.h" +#include "BKE_global.h" +#include "BKE_report.h" #include "ED_logic.h" #include "ED_object.h" @@ -746,6 +748,11 @@ static int component_add_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); char import[MAX_NAME]; + if ((G.f & G_SCRIPT_AUTOEXEC) == 0) { + BKE_report(op->reports, RPT_WARNING, "Python script/component auto-execution disable, look in the userpref to activate..."); + return OPERATOR_CANCELLED; + } + if (!ob) { return OPERATOR_CANCELLED; } @@ -836,6 +843,11 @@ static int component_reload_exec(bContext *C, wmOperator *op) PythonComponent *pc = NULL, *prev_pc = NULL; int index = RNA_int_get(op->ptr, "index"); + if ((G.f & G_SCRIPT_AUTOEXEC) == 0) { + BKE_report(op->reports, RPT_WARNING, "Python script/component auto-execution disable, look in the userpref to activate..."); + return OPERATOR_CANCELLED; + } + if(!ob) { return OPERATOR_CANCELLED; } diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index f0313601c3ae..0efeb489b316 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -4036,7 +4036,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) prop = RNA_def_property(srna, "use_scripts_auto_execute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_SCRIPT_AUTOEXEC_DISABLE); - RNA_def_property_ui_text(prop, "Auto Run Python Scripts", + RNA_def_property_ui_text(prop, "Auto Run Python Scripts and Components", "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"); diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index ae09af48a40b..1ba0daf51bdd 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1730,18 +1730,23 @@ void BL_ConvertBlenderObjects(struct Main *maggie, gameobj->ResetState(); } - // Convert the python components of each object. - for (KX_GameObject *gameobj : sumolist) { - Object *blenderobj = gameobj->GetBlenderObject(); - BL_ConvertComponentsObject(gameobj, blenderobj); - } + // Convert the python components of each object if the component execution is available. + if (G.f & G_SCRIPT_AUTOEXEC) { + for (KX_GameObject *gameobj : sumolist) { + Object *blenderobj = gameobj->GetBlenderObject(); + BL_ConvertComponentsObject(gameobj, blenderobj); + } - for (KX_GameObject *gameobj : objectlist) { - if (gameobj->GetComponents()) { - // Register object for component update. - kxscene->GetPythonComponentManager().RegisterObject(gameobj); + for (KX_GameObject *gameobj : objectlist) { + if (gameobj->GetComponents()) { + // Register object for component update. + kxscene->GetPythonComponentManager().RegisterObject(gameobj); + } } } + else { + CM_Warning("Python components auto-execution disabled"); + } // Cleanup converted set of group objects. convertedlist->Release();