Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-01-18 13:02:55 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-01-18 13:02:55 +0300
commite723b060fc596876ec4778589a5d6c88027187db (patch)
treeb49e68fdc5d2715fe4c2cfb9b23b6f174a1ed70c /release/scripts/modules/bpy/__init__.py
parent7195345c03f74680fa5e911e1acd217724140fee (diff)
python script reloading (f8)
- reload modules from types that are not directly included. for example wm.py uses classes from modules/rna_prop_ui.py which wasnt reloaded. - script paths were being added to sys.path multiple times. note: now the second reload gives a crash right away but this is a bug elsewhere.
Diffstat (limited to 'release/scripts/modules/bpy/__init__.py')
-rw-r--r--release/scripts/modules/bpy/__init__.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/release/scripts/modules/bpy/__init__.py b/release/scripts/modules/bpy/__init__.py
index c760268d6f7..28f082c9bd1 100644
--- a/release/scripts/modules/bpy/__init__.py
+++ b/release/scripts/modules/bpy/__init__.py
@@ -46,7 +46,11 @@ def load_scripts(reload_scripts=False):
t_main = time.time()
+ loaded_modules = set()
+
def test_import(module_name):
+ if module_name in loaded_modules:
+ return None
if "." in module_name:
print("Ignoring '%s', can't import files containing multiple periods." % module_name)
return None
@@ -61,12 +65,25 @@ def load_scripts(reload_scripts=False):
traceback.print_exc()
return None
+ if reload_scripts:
+ # reload modules that may not be directly included
+ for type_class_name in dir(types):
+ type_class = getattr(types, type_class_name)
+ module_name = getattr(type_class, "__module__", "")
+
+ if module_name and module_name != "bpy.types": # hard coded for C types
+ loaded_modules.add(module_name)
+
+ for module_name in loaded_modules:
+ print("Reloading:", module_name)
+ reload(sys.modules[module_name])
for base_path in utils.script_paths():
for path_subdir in ("ui", "op", "io"):
path = os.path.join(base_path, path_subdir)
if os.path.isdir(path):
- sys.path.insert(0, path)
+ if path not in sys.path: # reloading would add twice
+ sys.path.insert(0, path)
for f in sorted(os.listdir(path)):
if f.endswith(".py"):
# python module