From b490848bc9055b0e439fca88c1438d60885ffabb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janar=20S=C3=B6=C3=B6t?= Date: Fri, 14 Aug 2020 20:42:33 +0300 Subject: [PATCH] menu: fix for overwriting existing menu item (#3189) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In case of an overwriting existing menu item, the new item was added additionally to the end of the items list. Signed-off-by: Janar Sööt --- klippy/extras/display/menu.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/klippy/extras/display/menu.py b/klippy/extras/display/menu.py index 7dc05864..f565529b 100644 --- a/klippy/extras/display/menu.py +++ b/klippy/extras/display/menu.py @@ -934,14 +934,16 @@ class MenuManager: config, 'type', menu_items)(self, config) def add_menuitem(self, name, item): + existing_item = False if name in self.menuitems: + existing_item = True logging.info( "Declaration of '%s' hides " "previous menuitem declaration" % (name,)) self.menuitems[name] = item if isinstance(item, MenuElement): parent = item.get_ns('..') - if parent: + if parent and not existing_item: if item.index is not None: self.children.setdefault(parent, []).insert( item.index, item.get_ns())