gui.document: fix RenameLayer exception

As reported in https://gna.org/bugs/?22182