diff options
author | gm10 <[email protected]> | 2019-02-19 18:52:03 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2019-03-11 09:03:40 +0100 |
commit | 30caedb0c53281859d7fb724dea9cd96c796990c (patch) | |
tree | 440712b15adb776a70fc35058fc62e5e0f5cdb90 | |
parent | 7a677fef667a866bf6de6d179cbf9dbf2c7291f7 (diff) | |
download | mozo-30caedb0c53281859d7fb724dea9cd96c796990c.tar.bz2 mozo-30caedb0c53281859d7fb724dea9cd96c796990c.tar.xz |
Fix moving a menu corrupting the menu
-rw-r--r-- | Mozo/MenuEditor.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Mozo/MenuEditor.py b/Mozo/MenuEditor.py index 17315da..f94d591 100644 --- a/Mozo/MenuEditor.py +++ b/Mozo/MenuEditor.py @@ -88,6 +88,7 @@ class MenuEditor(object): with codecs.open(getattr(self, menu).path, 'w', 'utf-8') as f: f.write(getattr(self, menu).dom.toprettyxml()) if not from_loading: + self.load() self.__loadMenus() def quit(self): @@ -425,11 +426,9 @@ class MenuEditor(object): if menu.get_parent() != new_parent: dom = self.__getMenu(menu).dom path = self.__getPath(menu) - root_path = path[0] - xml_root = self.__getXmlMenu(root_path, dom.documentElement, dom) - old_path = path[1:] - new_path = self.__getPath(new_parent)[1:] + [menu.get_menu_id()] - self.__addXmlMove(xml_root, '/'.join(old_path), '/'.join(new_path), dom) + xml_root = self.__getXmlMenu(path[0], dom.documentElement, dom) + new_path = self.__getPath(new_parent) + [menu.get_menu_id()] + self.__addXmlMove(xml_root, '/'.join(path), '/'.join(new_path), dom) self.__positionItem(new_parent, menu, before, after) self.__addUndo([self.__getMenu(new_parent),]) self.save() @@ -578,6 +577,8 @@ class MenuEditor(object): return None def __getXmlMenu(self, path, element, dom): + if isinstance(path, str): + return element for name in path: found = self.__getXmlMenuPart(element, name) if found is not None: |