From ed3a7bd299c4b6a0ed2712065be7ca59da9931fe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Jun 2010 08:15:43 +0000 Subject: script reload (f8), is closer to working. there are internal memory problems which can make it crash still. If you remove all directories in the scripts folder except for 'modules' and 'ui', it runs without crashes. --- source/blender/editors/space_script/script_edit.c | 20 ++++++++++++++++++++ source/blender/editors/space_script/script_intern.h | 1 + source/blender/editors/space_script/script_ops.c | 1 + 3 files changed, 22 insertions(+) (limited to 'source/blender/editors/space_script') diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c index 6ef9a96b478..02993549c94 100644 --- a/source/blender/editors/space_script/script_edit.c +++ b/source/blender/editors/space_script/script_edit.c @@ -84,3 +84,23 @@ void SCRIPT_OT_python_file_run(wmOperatorType *ot) RNA_def_string_file_path(ot->srna, "path", "", 512, "Path", ""); } + +static int script_reload_exec(bContext *C, wmOperator *op) +{ +#ifndef DISABLE_PYTHON + BPY_eval_string(C, "__import__('bpy').utils.load_scripts(reload_scripts=True)"); + return OPERATOR_FINISHED; +#endif + return OPERATOR_CANCELLED; +} + +void SCRIPT_OT_reload(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Reload Scripts"; + ot->description= "Reload Scripts"; + ot->idname= "SCRIPT_OT_reload"; + + /* api callbacks */ + ot->exec= script_reload_exec; +} diff --git a/source/blender/editors/space_script/script_intern.h b/source/blender/editors/space_script/script_intern.h index 57e4cc6c793..ed625bb8ec6 100644 --- a/source/blender/editors/space_script/script_intern.h +++ b/source/blender/editors/space_script/script_intern.h @@ -39,6 +39,7 @@ void script_operatortypes(void); void script_keymap(struct wmKeyConfig *keyconf); /* script_edit.c */ +void SCRIPT_OT_reload(struct wmOperatorType *ot); void SCRIPT_OT_python_file_run(struct wmOperatorType *ot); #endif /* ED_SCRIPT_INTERN_H */ diff --git a/source/blender/editors/space_script/script_ops.c b/source/blender/editors/space_script/script_ops.c index 353d80f1921..61f7cf425d4 100644 --- a/source/blender/editors/space_script/script_ops.c +++ b/source/blender/editors/space_script/script_ops.c @@ -55,6 +55,7 @@ void script_operatortypes(void) { WM_operatortype_append(SCRIPT_OT_python_file_run); + WM_operatortype_append(SCRIPT_OT_reload); } void script_keymap(wmKeyConfig *keyconf) -- cgit v1.2.3