Make SdlDrop and SubsystemDrop safer to use #1254
Merged
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.
Fixes #1247 and #1248. Ensures better initialization/drop guarantees for
SdlDrop
andSubsystemDrop
by using global reference counts. This has a few caveats:SdlDrop
can no longer be initialized from outside thecrate::sdl
module. Any external code depending on this (hopefully there was none because this is extremely unsafe) will break.SdlDrop
andSubsystemDrop
are no longer wrapped inRc<>
. Any external code depending on these functions will break. It would be possible to reverse this change, but with global reference counting, there is no longer any good reason to do so.The fixes caused at least one of the tests to break because tests are run in parallel by default, and more than one test initializes SDL. Now that this can only be done from one thread, one must specify--test-threads=1
for the tests to pass. Maybe this was already the case, but I didn't check before making these changes. Example:cargo test -- --test-threads=1
Because the first two caveats are API breaks, even if hidden from documentation, I recommend a version bump to 0.36.0 if these changes are accepted.