::createMenu sometimes creates a new menu, sometimes returns a pointer
to a menu from libdbusmenu that we shouldn't delete.
This patch makes any newly created menu delete itself on closure.
It then shuffles some code so that we only call createMenu after
doing checks.