Skip to content

Commit

Permalink
Fix warnings registering sverchok menus after reenabling addon (#5170)
Browse files Browse the repository at this point in the history
E.g. if you disable and enable addon it would give the warnings below since menu classes were not unregistered.

Example warnings:
```
register_class(...):
Info: Registering menu class: 'SV_MT_PyMenu_Advanced', bl_idname 'SV_MT_PyMenu_Advanced' has been registered before, unregistering previous
register_class(...):
Info: Registering menu class: 'SV_MT_PyMenu_Architecture', bl_idname 'SV_MT_PyMenu_Architecture' has been registered before, unregistering previous
register_class(...):
Info: Registering menu class: 'SV_MT_PyMenu_CNC', bl_idname 'SV_MT_PyMenu_CNC' has been registered before, unregistering previous
register_class(...):
Info: Registering menu class: 'SV_MT_PyMenu_Design', bl_idname 'SV_MT_PyMenu_Design' has been registered before, unregistering previous
register_class(...):
Info: Registering menu class: 'SV_MT_PyMenu_Fields', bl_idname 'SV_MT_PyMenu_Fields' has been registered before, unregistering previous
register_class(...):
Info: Registering menu class: 'SV_MT_PyMenu_Introduction', bl_idname 'SV_MT_PyMenu_Introduction' has been registered before, unregistering previous
register_class(...):
Info: Registering menu class: 'SV_MT_PyMenu_Shapes', bl_idname 'SV_MT_PyMenu_Shapes' has been registered before, unregistering previous
register_class(...):
Info: Registering menu class: 'SV_MT_PyMenu_Surfaces', bl_idname 'SV_MT_PyMenu_Surfaces' has been registered before, unregistering previous
```
  • Loading branch information
Andrej730 authored Dec 2, 2024
1 parent c284a21 commit 8ad69dc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ui/sv_examples_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,12 @@ def execute(self, context):


classes = [SW_OT_Console, SV_MT_LayoutsExamples, SvNodeTreeImporterSilent]
submenu_classes = []


def register():
submenu_classes = (make_submenu_classes(path, category_name) for path, category_name in example_categories_names())
global submenu_classes
submenu_classes = [make_submenu_classes(path, category_name) for path, category_name in example_categories_names()]
_ = [bpy.utils.register_class(cls) for cls in chain(classes, submenu_classes)]
bpy.types.NODE_HT_header.append(node_examples_pulldown)
bpy.types.NODE_HT_header.append(node_settings_pulldown)
Expand All @@ -130,4 +132,4 @@ def register():
def unregister():
bpy.types.NODE_HT_header.remove(node_settings_pulldown)
bpy.types.NODE_HT_header.remove(node_examples_pulldown)
_ = [bpy.utils.unregister_class(cls) for cls in reversed(classes)]
_ = [bpy.utils.unregister_class(cls) for cls in reversed(list(chain(classes, submenu_classes)))]

0 comments on commit 8ad69dc

Please sign in to comment.