diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-04-23 10:58:02 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-04-23 10:58:02 +0400 |
commit | 1ed95e0450d9d7e5a98141b209640ffd0283ab9d (patch) | |
tree | 0431979195c7cd2ce86dc9b28e3038311d7b3556 /source/blender/python | |
parent | d00c3ef2d6339aa01ddbc56bacd20f1ef4473a27 (diff) |
F8Key reloads all python scripts and redraws for quick testing
F7 runs test.py also for testing
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/BPY_extern.h | 2 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 14 |
2 files changed, 11 insertions, 5 deletions
diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h index d8e4611d9df..ff3e89a6e25 100644 --- a/source/blender/python/BPY_extern.h +++ b/source/blender/python/BPY_extern.h @@ -99,7 +99,7 @@ extern "C" { /* 2.5 UI Scripts */ int BPY_run_python_script( struct bContext *C, const char *filename, struct Text *text ); // 2.5 working int BPY_run_script_space_draw(struct bContext *C, struct SpaceScript * sc); // 2.5 working - void BPY_run_ui_scripts(struct bContext *C); + void BPY_run_ui_scripts(struct bContext *C, int reload); // int BPY_run_script_space_listener(struct bContext *C, struct SpaceScript * sc, struct ARegion *ar, struct wmNotifier *wmn); // 2.5 working void BPY_update_modules( void ); // XXX - annoying, need this for pointers that get out of date diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index c2773e9e7d1..f37137aa42c 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -347,7 +347,7 @@ int BPY_run_python_script_space(const char *modulename, const char *func) #endif /* XXX this is temporary, need a proper script registration system for 2.5 */ -void BPY_run_ui_scripts(bContext *C) +void BPY_run_ui_scripts(bContext *C, int reload) { #ifdef TIME_REGISTRATION double time = PIL_check_seconds_timer(); @@ -396,13 +396,19 @@ void BPY_run_ui_scripts(bContext *C) mod= PyImport_ImportModuleLevel(path, NULL, NULL, NULL, 0); if (mod) { - Py_DECREF(mod); + if (reload) { + PyObject *mod_orig= mod; + mod= PyImport_ReloadModule(mod); + Py_DECREF(mod_orig); + } } - else { + + if(mod) { + Py_DECREF(mod); /* could be NULL from reloading */ + } else { PyErr_Print(); fprintf(stderr, "unable to import \"%s\" %s/%s\n", path, dirname, de->d_name); } - } } |