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:
authorLukas Toenne <lukas.toenne@googlemail.com>2013-08-28 10:36:54 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2013-08-28 10:36:54 +0400
commit771906bc09317e3dc77be2319b44bc59081eff93 (patch)
tree2b6386aa5cdadfd52bc3b036feee3b00b6c87793 /release/scripts/startup/bl_operators/wm.py
parentf75711db7fd3565925880f8a2ea89088334c35bf (diff)
Fix for #36387, User Preferences "Addons" panel bogs down the whole interface.
The addons panel draw function calls addon_utils.modules() which in turn retrieves a list of fake modules from the script paths every time. This can become costly when network paths are included for addons. Solution is to put the scanning process into a dedicated "refresh" function and disable it in frequently called draw and filter functions, i.e. in these cases the cached addons_fake_modules list will be used instead. Note that this may lead to invalid addon lists if script paths are changed (which is not working 100% without restart anyway according to Campbell). For this there is now a "Refresh" operator button in the addons preferences. If necessary and feasible such forced refreshes can be added later too.
Diffstat (limited to 'release/scripts/startup/bl_operators/wm.py')
-rw-r--r--release/scripts/startup/bl_operators/wm.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 5095bfdd9d2..c575b6dfdaf 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -1693,6 +1693,19 @@ class WM_OT_theme_install(Operator):
return {'RUNNING_MODAL'}
+class WM_OT_addon_refresh(Operator):
+ "Scan addon directories for new modules"
+ bl_idname = "wm.addon_refresh"
+ bl_label = "Refresh"
+
+ def execute(self, context):
+ import addon_utils
+
+ addon_utils.modules_refresh()
+
+ return {'FINISHED'}
+
+
class WM_OT_addon_install(Operator):
"Install an addon"
bl_idname = "wm.addon_install"
@@ -1782,7 +1795,7 @@ class WM_OT_addon_install(Operator):
del pyfile_dir
# done checking for exceptional case
- addons_old = {mod.__name__ for mod in addon_utils.modules(addon_utils.addons_fake_modules)}
+ addons_old = {mod.__name__ for mod in addon_utils.modules()}
#check to see if the file is in compressed format (.zip)
if zipfile.is_zipfile(pyfile):
@@ -1825,7 +1838,7 @@ class WM_OT_addon_install(Operator):
traceback.print_exc()
return {'CANCELLED'}
- addons_new = {mod.__name__ for mod in addon_utils.modules(addon_utils.addons_fake_modules)} - addons_old
+ addons_new = {mod.__name__ for mod in addon_utils.modules()} - addons_old
addons_new.discard("modules")
# disable any addons we may have enabled previously and removed.
@@ -1835,7 +1848,7 @@ class WM_OT_addon_install(Operator):
# possible the zip contains multiple addons, we could disallow this
# but for now just use the first
- for mod in addon_utils.modules(addon_utils.addons_fake_modules):
+ for mod in addon_utils.modules(refresh=False):
if mod.__name__ in addons_new:
info = addon_utils.module_bl_info(mod)
@@ -1875,7 +1888,7 @@ class WM_OT_addon_remove(Operator):
import os
import addon_utils
- for mod in addon_utils.modules(addon_utils.addons_fake_modules):
+ for mod in addon_utils.modules():
if mod.__name__ == module:
filepath = mod.__file__
if os.path.exists(filepath):