Fix some Game members not being freed after some startup errors (regression) #14561
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a regression from fd8e021. In that commit, I moved some freeing from
Game::~Game
toGame::shutdown
. Now I realize thatGame::shutdown
isn't called in all cases, for example when a shader compilation error occurs.Behavior in case of a shader compilation error:
This PR works by always calling
Game::shutdown
. Somewhat related old PR: #9742To do
This PR is a Ready for Review.
Notes:
I think the stuff I moved from
Game::~Game
toGame::shutdown
could actually be moved back. However, that would mean spawning a thread (StopThread) and rendering the shutdown screen in a destructor, which feels bad. What if one of these things throws an exception? Would this be a better solution?Could always calling
Game::shutdown
introduce new bugs?How to test
Edit shaders to make shader compilation fail. Add this code to
builtin/game/init.lua
:Verify that the behavior of different versions matches what I describe in the table above.