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.
This commit is contained in:
@@ -35,7 +35,6 @@ error_duplicates = False
|
||||
error_encoding = False
|
||||
addons_fake_modules = {}
|
||||
|
||||
|
||||
def paths():
|
||||
# RELEASE SCRIPTS: official scripts distributed in Blender releases
|
||||
addon_paths = _bpy.utils.script_paths("addons")
|
||||
@@ -51,7 +50,7 @@ def paths():
|
||||
return addon_paths
|
||||
|
||||
|
||||
def modules(module_cache):
|
||||
def modules_refresh(module_cache=addons_fake_modules):
|
||||
global error_duplicates
|
||||
global error_encoding
|
||||
import os
|
||||
@@ -184,6 +183,11 @@ def modules(module_cache):
|
||||
del module_cache[mod_stale]
|
||||
del modules_stale
|
||||
|
||||
|
||||
def modules(module_cache=addons_fake_modules, refresh=True):
|
||||
if refresh:
|
||||
modules_refresh(module_cache)
|
||||
|
||||
mod_list = list(module_cache.values())
|
||||
mod_list.sort(key=lambda mod: (mod.bl_info["category"],
|
||||
mod.bl_info["name"],
|
||||
@@ -370,6 +374,9 @@ def reset_all(reload_scripts=False):
|
||||
"""
|
||||
import sys
|
||||
|
||||
# initializes addons_fake_modules
|
||||
modules_refresh()
|
||||
|
||||
# RELEASE SCRIPTS: official scripts distributed in Blender releases
|
||||
paths_list = paths()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user