Game crashes on reset when forcefully updating battle scene

Why does this cause the game to crash on F12?

How to reproduce

1: Insert script below materials

2: Start battle test

3: Press F12

class Game_Battler alias 😮ld_add_new_state :add_new_state def add_new_state(state_id) old_add_new_state(state_id) SceneManager.scene.wait_for_animation if SceneManager.scene_is?(Scene_Battle) endendThe idea is that whenever a new state is added, some animation is played, and so I want the battle scene to wait while the animation is played out.How can it be fixed?
The error displayed for me with that is "Window_Base in line 83 : disposed window".

The default reset behavior is kind of weird, to be honest. It is not reinitializing the graphics and all. If I try to reset in my game in battle, there would still be some leftover windows.
Now, this fixes the problem


http://forums.rpgmakerweb.com/index.php?/topic/8000-f12-reset-fix/


But it's basically spawning a new process...which for some reason works.
Spawning new process will work, as it is a brand new process...

Apparently, making the Graphics transition for some seconds also work for some reason.

Code:
rgss_main {  begin    SceneManager.run  rescue RGSSReset    Graphics.transition(10)  end}
Although, using this will oftentimes leave the current screen's windows in the screen.
I find it strange that spawning a new process would work in the first place.
The RPG Maker's RGSS3Player is just an ordinary RGSS3 interpreter after all.

Though, leaving that method call exposed is quite dangerous. Who knows what kind of malicious programs that can be called....
SceneManager::scene should return nil when your modified Game_Battler#add_new_state is called (indirectly by DataManager::init). At that moment it's still the previous Scene_Battle instance but “broken”. I'm not sure what the best way to fix this bug (?) is as I'm not really familiar with the VX Ace standard scripts.

If you don't want to restart the game, this fixes resets during battle test.

Code:
rgss_main do  begin    SceneManager.run  rescue RGSSReset => e    SceneManager.exit if $BTEST  # `if` might be unnecessary    fail e  endend
Maybe you have or someone else has a better idea?

Original thread: https://forums.rpgmakerweb.com/threads/game-crashes-on-reset-when-forcefully-updating-battle-scene.25468/