diff options
Diffstat (limited to 'release/scripts/modules/addon_utils.py')
-rw-r--r-- | release/scripts/modules/addon_utils.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index 5cb313ec41b..f73d23c150b 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -362,9 +362,38 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non _addon_remove(module_name) return None + # 1.1) fail when add-on is too old + # This is a temporary 2.8x migration check, so we can manage addons that are supported. + + # Silent default, we know these need updating. + if module_name in { + "io_anim_bvh", + "io_mesh_ply", + "io_mesh_stl", + "io_mesh_uv_layout", + "io_scene_3ds", + "io_scene_fbx", + "io_scene_obj", + "io_scene_x3d", + }: + return None + + try: + if mod.bl_info.get("blender", (0, 0, 0)) < (2, 80, 0): + raise Exception(f"Add-on '{module_name:s}' has not been upgraded to 2.8, ignoring") + except Exception as ex: + handle_error(ex) + return None + # 2) try register collected modules # removed, addons need to handle own registration now. + use_owner = mod.bl_info.get("use_owner", True) + if use_owner: + from _bpy import _bl_owner_id_get, _bl_owner_id_set + owner_id_prev = _bl_owner_id_get() + _bl_owner_id_set(module_name) + # 3) try run the modules register function try: mod.register() @@ -378,6 +407,9 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non if default_set: _addon_remove(module_name) return None + finally: + if use_owner: + _bl_owner_id_set(owner_id_prev) # * OK loaded successfully! * mod.__addon_enabled__ = True @@ -491,6 +523,7 @@ def module_bl_info(mod, info_basis=None): "category": "", "warning": "", "show_expanded": False, + "use_owner": True, } addon_info = getattr(mod, "bl_info", {}) @@ -508,5 +541,9 @@ def module_bl_info(mod, info_basis=None): if not addon_info["name"]: addon_info["name"] = mod.__name__ + # Temporary auto-magic, don't use_owner for import export menus. + if mod.bl_info["category"] == "Import-Export": + mod.bl_info["use_owner"] = False + addon_info["_init"] = None return addon_info |