Crash when switching sample with external envelope editor

See also BUG: deleting an envelope that is open in ext. editor causes a sigsegv on MacOS

Could never replicate this here, maybe it only happens on macOS (for whatever reason) so I’ll check that there too.