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",
|
"name": "Background plane manager",
|
||||||
"description": "Manage the background image planes and grease pencil object relative to a camera",
|
"description": "Manage the background image planes and grease pencil object relative to a camera",
|
||||||
"author": "Samuel Bernou",
|
"author": "Samuel Bernou",
|
||||||
"version": (0, 5, 2),
|
"version": (0, 5, 3),
|
||||||
"blender": (3, 5, 0),
|
"blender": (3, 5, 0),
|
||||||
"location": "View3D",
|
"location": "View3D",
|
||||||
"warning": "",
|
"warning": "",
|
||||||
|
@ -14,6 +14,7 @@ bl_info = {
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from bpy.app.handlers import persistent
|
||||||
|
|
||||||
from . import operators
|
from . import operators
|
||||||
from . import import_planes
|
from . import import_planes
|
||||||
|
@ -59,6 +60,11 @@ except Exception:
|
||||||
# TODO: Add an enum in prefs to choose default type to use
|
# TODO: Add an enum in prefs to choose default type to use
|
||||||
# Override this enum if there is an environement variable in project
|
# 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 = (
|
modules = (
|
||||||
import_planes,
|
import_planes,
|
||||||
operators,
|
operators,
|
||||||
|
@ -71,8 +77,11 @@ def register():
|
||||||
for m in modules:
|
for m in modules:
|
||||||
m.register()
|
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():
|
def unregister():
|
||||||
|
bpy.app.handlers.load_post.remove(subscribe_tab_update)
|
||||||
for m in reversed(modules):
|
for m in reversed(modules):
|
||||||
m.unregister()
|
m.unregister()
|
||||||
|
|
|
@ -17,7 +17,7 @@ def ui_in_sidebar_update(self, _):
|
||||||
if hasattr(bpy.types, BPM_PT_bg_manager_panel.bl_idname):
|
if hasattr(bpy.types, BPM_PT_bg_manager_panel.bl_idname):
|
||||||
try:
|
try:
|
||||||
bpy.utils.unregister_class(BPM_PT_bg_manager_panel)
|
bpy.utils.unregister_class(BPM_PT_bg_manager_panel)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
BPM_PT_bg_manager_panel.bl_category = self.category.strip()
|
BPM_PT_bg_manager_panel.bl_category = self.category.strip()
|
||||||
|
|
Loading…
Reference in New Issue