Fix tab name update call at register, now in load handler
Fail in background mode with --addons flag to force enable addon. should not be in register since it should happen after a full register.master
parent
d0a413b4bf
commit
6d64d6df7f
13
__init__.py
13
__init__.py
|
@ -4,7 +4,7 @@ bl_info = {
|
|||
"name": "Background plane manager",
|
||||
"description": "Manage the background image planes and grease pencil object relative to a camera",
|
||||
"author": "Samuel Bernou",
|
||||
"version": (0, 5, 2),
|
||||
"version": (0, 5, 3),
|
||||
"blender": (3, 5, 0),
|
||||
"location": "View3D",
|
||||
"warning": "",
|
||||
|
@ -14,6 +14,7 @@ bl_info = {
|
|||
|
||||
import bpy
|
||||
from pathlib import Path
|
||||
from bpy.app.handlers import persistent
|
||||
|
||||
from . import operators
|
||||
from . import import_planes
|
||||
|
@ -59,6 +60,11 @@ except Exception:
|
|||
# TODO: Add an enum in prefs to choose default type to use
|
||||
# Override this enum if there is an environement variable in project
|
||||
|
||||
@persistent
|
||||
def subscribe_tab_update(dummy):
|
||||
## Update UI Tab name in sidebar
|
||||
preferences.ui_in_sidebar_update(core.get_addon_prefs(), bpy.context)
|
||||
|
||||
modules = (
|
||||
import_planes,
|
||||
operators,
|
||||
|
@ -71,8 +77,11 @@ def register():
|
|||
for m in modules:
|
||||
m.register()
|
||||
|
||||
preferences.ui_in_sidebar_update(core.get_addon_prefs(), bpy.context)
|
||||
## Update UI Tab name in sidebar (Disabled : cause Error in CLI when enabling addon with "--addons" flag)
|
||||
# preferences.ui_in_sidebar_update(core.get_addon_prefs(), bpy.context)
|
||||
bpy.app.handlers.load_post.append(subscribe_tab_update)
|
||||
|
||||
def unregister():
|
||||
bpy.app.handlers.load_post.remove(subscribe_tab_update)
|
||||
for m in reversed(modules):
|
||||
m.unregister()
|
||||
|
|
|
@ -17,7 +17,7 @@ def ui_in_sidebar_update(self, _):
|
|||
if hasattr(bpy.types, BPM_PT_bg_manager_panel.bl_idname):
|
||||
try:
|
||||
bpy.utils.unregister_class(BPM_PT_bg_manager_panel)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
BPM_PT_bg_manager_panel.bl_category = self.category.strip()
|
||||
|
|
Loading…
Reference in New Issue