Skip to content

Commit 466ac0c

Browse files
Fix menu creation if two dividers are in a menu
For example a menu definition like this: ``` "display_tools/---Viewport", "display_tools/center_twodee", "display_tools/center_twodee_remove", "display_tools/center_twodee_ui", "display_tools/---", "display_tools/cycle_active_viewport_display_preset_forward", "display_tools/cycle_active_viewport_display_preset_backward", "display_tools/---", "display_tools/toggle_viewport_geom", "display_tools/toggle_viewport_ctrls", "display_tools/toggle_viewport_imgplns", ``` Before this bug fix, one of the '"display_tools/---",' dividers would not be created.
1 parent bb4d541 commit 466ac0c

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

python/mmSolver/tools/mmmenu/lib.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ def create_items(items_to_create, main_parent):
153153
created_items = {}
154154
for key, parent_key, func_def, is_sub_menu in items_to_create:
155155
menu_item = created_items.get(key)
156-
if menu_item is not None:
156+
# We are able to have the same key multiple times if it is a
157+
# divider without a name.
158+
divider = key.endswith('---')
159+
if menu_item is not None and divider is not True:
157160
continue
158161
parent = created_items.get(parent_key)
159162
if parent is None:

python/mmSolver/tools/mmshelf/lib.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,10 @@ def create_items(items_to_create, main_parent):
206206
created_items = {}
207207
for key, parent_key, func_def, is_first_item, is_last_item in items_to_create:
208208
items = created_items.get(key)
209-
if items is not None:
209+
# We are able to have the same key multiple times if it is a
210+
# divider without a name.
211+
divider = key.endswith('---')
212+
if items is not None and divider is not True:
210213
continue
211214

212215
parents = created_items.get(parent_key)

0 commit comments

Comments
 (0)