Ensure X11 connections are closed #3924
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.
Checklist
cargo clippy
.cargo clippy --target wasm32-unknown-unknown
if applicable.Connections
#3813
Description
Introduces a DisplayOwner struct to own both the library and associated display pointer; their lifetimes are combined in that struct.
The display pointer is encapsulated in a DisplayRef.
When DisplayOwner is dropped, it ensures that the DisplayRef is correctly closed prior to unloading the library.
This PR looks bigger than it really is because of rustfmt'd whitespace changes in the main part of the code.
Testing
As explained in #3813, the hello example is modified to create multiple Instances, and then pause before shutting down the program.
Then in another window:
lsof -p $(pgrep hello) | grep STREAM | wc -l
is used to count the number of open descriptors. Prior to this change the count correlated with the number of Instances created by the program. With this change there are 0.Note: the state of trunk at the moment has a unexpectedly passing test; that is not due to this change: