Fix T58842: Add-ons Import/Export entries disapear when enabling Filter

Addons option

This removes the 'use_owner' option feature from rB61c8ed40f5df.
(this wasnt working well when addons are enabled and when switching
workspaces)

Now Addon filtering is just bypassed for Import/Export menus.
(by introducing/setting bl_owner_use_filter = False)

Maniphest Tasks: T58842

Differential Revision: https://developer.blender.org/D6740
This commit is contained in:
Philipp Oeser
2020-02-03 12:49:09 +01:00
parent 36d09d9029
commit 0bedf9cf07
4 changed files with 10 additions and 15 deletions

View File

@@ -373,11 +373,9 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non
# 2) Try register collected modules.
# Removed register_module, addons need to handle their 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)
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:
@@ -393,8 +391,7 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non
_addon_remove(module_name)
return None
finally:
if use_owner:
_bl_owner_id_set(owner_id_prev)
_bl_owner_id_set(owner_id_prev)
# * OK loaded successfully! *
mod.__addon_enabled__ = True
@@ -513,7 +510,6 @@ def module_bl_info(mod, info_basis=None):
"category": "",
"warning": "",
"show_expanded": False,
"use_owner": True,
}
addon_info = getattr(mod, "bl_info", {})
@@ -531,9 +527,5 @@ 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

View File

@@ -783,7 +783,10 @@ class _GenericUI:
for func in draw_ls._draw_funcs:
# Begin 'owner_id' filter.
if owner_names is not None:
# Exclude Import/Export menus from this filtering (io addons should always show there)
if not getattr(self, "bl_owner_use_filter", True):
pass
elif owner_names is not None:
owner_id = getattr(func, "_owner", None)
if owner_id is not None:
if func._owner not in owner_names: