Fix crash when switching code editors on release builds

For some reason saving first and then dispatching the view change prevents a memory issue.