diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-01-23 08:20:37 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-01-23 08:38:29 +0300 |
commit | 7733bd5efc8e90f85385e5a93066158a17b14a93 (patch) | |
tree | 175139f1a6ec9a3e4e89bb8ed8e09c8d2756a3b5 /release/scripts/modules/addon_utils.py | |
parent | 783b4cd1ca22de57c98ebcfaeec7a20936a9a621 (diff) |
PyAPI: avoid scanning all addons on startup
Gives small speedup
Diffstat (limited to 'release/scripts/modules/addon_utils.py')
-rw-r--r-- | release/scripts/modules/addon_utils.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index d236a59059f..9ec6d249129 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -36,6 +36,15 @@ error_encoding = False addons_fake_modules = {} +# called only once at startup, avoids calling 'reset_all', correct but slower. +def _initialize(): + path_list = paths() + for path in path_list: + _bpy.utils._sys_path_ensure(path) + for addon in _user_preferences.addons: + enable(addon.module) + + def paths(): # RELEASE SCRIPTS: official scripts distributed in Blender releases addon_paths = _bpy.utils.script_paths("addons") @@ -182,14 +191,16 @@ def modules_refresh(module_cache=addons_fake_modules): def modules(module_cache=addons_fake_modules, refresh=True): - if refresh: + if refresh or ((module_cache is addons_fake_modules) and modules._is_first): modules_refresh(module_cache) + modules._is_first = False mod_list = list(module_cache.values()) mod_list.sort(key=lambda mod: (mod.bl_info["category"], mod.bl_info["name"], )) return mod_list +modules._is_first = True def check(module_name): |