menu: fix for overwriting existing menu item (#3189)

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 <janar.soot@gmail.com>
This commit is contained in:
Janar Sööt 2020-08-14 20:42:33 +03:00 committed by GitHub
parent 7a615b4f69
commit b490848bc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -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())