diff options
-rw-r--r-- | release/scripts/modules/bpy/utils.py | 8 | ||||
-rw-r--r-- | release/scripts/op/wm.py | 13 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_script/script_edit.c | 20 | ||||
-rw-r--r-- | source/blender/editors/space_script/script_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_script/script_ops.c | 1 |
6 files changed, 31 insertions, 14 deletions
diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index cab5ee5e684..cdf79a760ba 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -144,6 +144,9 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): _loaded.append(mod) if reload_scripts: + + # TODO, this is broken but should work, needs looking into + ''' # reload modules that may not be directly included for type_class_name in dir(_bpy.types): type_class = getattr(_bpy.types, type_class_name) @@ -156,6 +159,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): for module_name in sorted(loaded_modules): print("Reloading:", module_name) test_reload(_sys.modules[module_name]) + ''' # loop over and unload all scripts _loaded.reverse() @@ -166,6 +170,10 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): unregister() except: traceback.print_exc() + + for mod in _loaded: + reload(mod) + _loaded[:] = [] user_path = user_script_path() diff --git a/release/scripts/op/wm.py b/release/scripts/op/wm.py index 0d204ce72ae..d04d6c7a1dd 100644 --- a/release/scripts/op/wm.py +++ b/release/scripts/op/wm.py @@ -543,17 +543,6 @@ class WM_OT_doc_edit(bpy.types.Operator): return wm.invoke_props_dialog(self, width=600) -class WM_OT_reload_scripts(bpy.types.Operator): - '''Load online reference docs''' - bl_idname = "wm.reload_scripts" - bl_label = "Reload Scripts" - - def execute(self, context): - MOD = type(bpy) - bpy.utils.load_scripts(True) - return {'FINISHED'} - - import rna_prop_ui classes = [ @@ -577,8 +566,6 @@ classes = [ WM_OT_doc_view, WM_OT_doc_edit, - WM_OT_reload_scripts, - # experemental! rna_prop_ui.WM_OT_properties_edit, rna_prop_ui.WM_OT_properties_add, diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 8b1c0045fd3..a91e6dddf75 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2998,7 +2998,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SCREEN_OT_repeat_last", RKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0); - WM_keymap_verify_item(keymap, "WM_OT_reload_scripts", F8KEY, KM_PRESS, 0, 0); + WM_keymap_verify_item(keymap, "SCRIPT_OT_reload", F8KEY, KM_PRESS, 0, 0); /* files */ WM_keymap_add_item(keymap, "FILE_OT_execute", RETKEY, KM_PRESS, 0, 0); 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) |