diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fd843b..5cea935 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog +2.1.4 + +- fixed: layer change msgbus not working at first activation of the addon + 2.1.3 - fixed: decoralate Prefix and Suffix UI_lists scroll diff --git a/OP_layer_manager.py b/OP_layer_manager.py index a048838..bce7ff1 100644 --- a/OP_layer_manager.py +++ b/OP_layer_manager.py @@ -675,8 +675,8 @@ def obj_layer_name_callback(): # print('inc:', res.group('inc')) bpy.context.scene.gptoolprops['layer_name'] = res.group('name') -@persistent -def subscribe_handler(dummy): + +def subscribe_layer_change(): subscribe_to = (bpy.types.GreasePencilLayers, "active_index") bpy.msgbus.subscribe_rna( key=subscribe_to, @@ -690,6 +690,9 @@ def subscribe_handler(dummy): options={'PERSISTENT'}, ) +@persistent +def subscribe_layer_change_handler(dummy): + subscribe_layer_change() ##--- Add layers @@ -813,12 +816,15 @@ def register(): bpy.types.DATA_PT_gpencil_layers.prepend(layer_name_builder_ui) bpy.types.DOPESHEET_HT_header.append(gpencil_dopesheet_header) bpy.types.GPENCIL_MT_layer_context_menu.append(gpencil_layer_dropdown_menu) - bpy.app.handlers.load_post.append(subscribe_handler) # need to restart after first activation + bpy.app.handlers.load_post.append(subscribe_layer_change_handler) register_keymaps() + # Directly set msgbus to work at first addon activation + bpy.app.timers.register(subscribe_layer_change, first_interval=1) + def unregister(): unregister_keymaps() - bpy.app.handlers.load_post.remove(subscribe_handler) + bpy.app.handlers.load_post.remove(subscribe_layer_change_handler) bpy.types.GPENCIL_MT_layer_context_menu.remove(gpencil_layer_dropdown_menu) bpy.types.DOPESHEET_HT_header.remove(gpencil_dopesheet_header) bpy.types.DATA_PT_gpencil_layers.remove(layer_name_builder_ui) diff --git a/__init__.py b/__init__.py index 0058766..8f1ecd3 100755 --- a/__init__.py +++ b/__init__.py @@ -4,7 +4,7 @@ bl_info = { "name": "GP toolbox", "description": "Tool set for Grease Pencil in animation production", "author": "Samuel Bernou, Christophe Seux", -"version": (2, 1, 3), +"version": (2, 1, 4), "blender": (3, 0, 0), "location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties", "warning": "",