
Not sure where that piece of code originates from, but trying to remap usages of deleted scene to newly active scene in *whole* bmain is really, really not the thing to do! Just use generic ID deletion code here, no reason it could not handle the task properly. ;)