Fix clipboard crashes in editor (fixes #318)