Applications menu disappears after failed xfce-applications.menu parsing while responding to changes - xfce-applications.menu is still being written to
Submitted by OmegaPhil
Assigned to Jannis Pohlmann
Description
I'm currently working on menulibre (https://launchpad.net/menulibre), and found that occasionally while making a few menu changes in succession the XFCE4 panel would pop up an error dialog:
============================================================
Failed to load the applications menu
Error on line 1205 char 19: Document ended unexpectedly inside an element name
============================================================
I have also seen 'Error on line 1 char 1: Document was empty or contained only whitespace'.
After OKing the dialog, the applications menu is empty (just a tiny square popping up from the button) and you have to restart the panel to recover from the situation.
This is much easier to trigger if you move an item up and down a menu quickly (note that menulibre is more efficient than alacarte so completes changes quite fast).
Looking into the code, the failure is happening in garcon-menu-parser.c:garcon_menu_parser_run, from either g_markup_parse_context_parse or the g_markup_parse_context_end_parse call (the actual error wording comes from the Glib source).
Presumably garcon is responding to the first committed change to a file, but tries to read it right in the middle of the next change, so naturally fails on junk content (editing these files really needs locking)...
When this situation happens, please could garcon try again a little later rather than giving up? Restarting the panel is fine for a programmer but not a normal user.
Thanks