Fix Sudden Crash from Exitting Main Loop #814
Open
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.
Synopsis
Issue #681 is still valid for the latest
master
version ofmacroquad
. This PR fixes the crash from this issue. The main reason it happens in the first place is as follows. Closes #681Macroquad apps are generally structured in the following way:
When you exit
main
afterdraw_circle
and alike, but beforenext_frame()
-- the context ofmacroquad
is left in a sort of bad state. It contains a lot drawcalls, but all the resources it points to are dead, because they were locals inmain()
. The event loop still callsend_frame
, which causesquad_gl.rs
to access a bunch of dangling references.This implicit "zones" in user's code, where they can or can not exit
The Fix
The fix this PR proposes is to force-reset the
quad_gl
stuff aftermain()
exits.Alternatives
DrawCall
quad_gl.rs
releases the strong refernecesend_frame
whenmain
exitslib.rs
a bit cleaner?main
has exited