Gui: fix a bug when restoring a layout