It is using WM_file_read to load a new .blend or when restart game is called instead of old "load_game_data".
We avoid to free pre-runtime wm->undo_stack during the whole runtime. At the end of runtime, WM_file_read is called again to load the pre-runtime file, and we assign the undo_stack that we saved to the wmWindowManager of the read file.
There is a remaining memory leak reported in console, i didn't find the cause.
EDIT: Not stable
It is using WM_file_read to load a new .blend or when restart game is called instead of old "load_game_data".
We avoid to free pre-runtime wm->undo_stack during the whole runtime. At the end of runtime, WM_file_read is called again to load the pre-runtime file, and we assign the undo_stack that we saved to the wmWindowManager of the read file.
There is a remaining memory leak reported in console, i didn't find the cause.
It is avoiding this assert: https://github.com/UPBGE/upbge/issues/1805
I tested with few test files (I don't have many "restart-load" files) and it sounds to work ok.
Test files used: restart-load.zip