applets/appmenu: handle apps lying about having a menu

Reason for the change

Apps can claim they have a menu, and then not actually give us one - System Settings does it (and shouldn't), but the same applies to third- party apps we can't control. This doesn't really matter much for full row global menus, but with a single button global menu it breaks in several ways - first, the button will look enabled even if it doesn't do anything, second and more disruptingly, trying to open the empty menu breaks the applet badly, it will wait forever for it to close and stops working until plasma is restarted (in any app, not just the lying one).

Instead, we guard against this twice: we disable the button if an app gives us an empty menu, and to make completely sure a fast clicker does not manage to hit it while the menu is still being fetched, we also make sure that the menu is not empty before showing it.

Test plan

  1. Add Global Menu to panel
  2. Configure global menu to have just a single button (Plasma might crash because of bug 489365, just try it a couple times if necessary)
  3. Launch System Settings
  4. Click Global Menu button

Screenshots or screen recordings

N/A

Bugs fixed

N/A

Merge request reports

Loading