bluesabre / menulibre

MenuLibre is an advanced menu editor that provides modern features in a clean, easy-to-use interface.
https://bluesabre.org/menulibre
GNU General Public License v3.0
212 stars 17 forks source link

Doesn't Handle Errors in `~/.config/menus/*-applications.menu` Files #104

Open AntumDeluge opened 2 years ago

AntumDeluge commented 2 years ago

If there is an error in the ~/.config/menus/*-applications.menu file, or if the file is empty, the app does not handle it & is left open in the background. It should at least end the process after printing the stacktrace.

I came across this issue trying to debug another issue (#95). And users generally shouldn't be editing these files manually, but either way it would be wise for the app the be able to close itself properly in the event of a parsing error like this.

I am running the app from master branch at commit e65e9542b1eadc21472732bf2f863421c7b4a1f9.

Empty file:

Traceback (most recent call last):
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenulibreApplication.py", line 2404, in do_activate
    self.win = MenulibreWindow(self, headerbar)
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenulibreApplication.py", line 260, in __init__
    self.configure_application_treeview(builder)
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenulibreApplication.py", line 637, in configure_application_treeview
    self.treeview = MenulibreTreeview.Treeview(self, builder)
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenulibreTreeview.py", line 53, in __init__
    if self._configure_treeview(builder):
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenulibreTreeview.py", line 67, in _configure_treeview
    treestore = MenuEditor.get_treestore()
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenuEditor.py", line 157, in get_treestore
    menus = get_menus()
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenuEditor.py", line 230, in get_menus
    menu = MenuEditor()
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenuEditor.py", line 297, in __init__
    self.load()
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenuEditor.py", line 317, in load
    if not self.tree.load_sync():
gi.repository.GLib.GError: g-markup-error-quark: Error on line 1 char 1: Document was empty or contained only whitespace (1)

Bad tag name:

Traceback (most recent call last):
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenulibreApplication.py", line 2404, in do_activate
    self.win = MenulibreWindow(self, headerbar)
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenulibreApplication.py", line 260, in __init__
    self.configure_application_treeview(builder)
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenulibreApplication.py", line 637, in configure_application_treeview
    self.treeview = MenulibreTreeview.Treeview(self, builder)
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenulibreTreeview.py", line 53, in __init__
    if self._configure_treeview(builder):
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenulibreTreeview.py", line 67, in _configure_treeview
    treestore = MenuEditor.get_treestore()
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenuEditor.py", line 157, in get_treestore
    menus = get_menus()
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenuEditor.py", line 230, in get_menus
    menu = MenuEditor()
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenuEditor.py", line 297, in __init__
    self.load()
  File "/home/jordan/Development/MenuLibre/code/menulibre/MenuEditor.py", line 317, in load
    if not self.tree.load_sync():
gi.repository.GLib.GError: g-markup-error-quark: Line 6 character 1: Line 6 character 1: Root element in a menu file must be <Menu>, not <Mensu>