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.
This commit is contained in:
2010-06-01 08:15:43 +00:00
parent c902eb8d7e
commit ed3a7bd299
6 changed files with 31 additions and 14 deletions

View File

@@ -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()

View File

@@ -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,

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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 */

View File

@@ -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)