do not destroy layers created outside the dialog (fix #7903)