Skip to content

Avoid unsafe in examples#4520

Open
madsmtm wants to merge 2 commits intomasterfrom
madsmtm/softbuffer-fill-remove
Open

Avoid unsafe in examples#4520
madsmtm wants to merge 2 commits intomasterfrom
madsmtm/softbuffer-fill-remove

Conversation

@madsmtm
Copy link
Copy Markdown
Member

@madsmtm madsmtm commented Mar 17, 2026

OwnedDisplayHandle (introduced in #3395) allows getting a reference-counted handle to the connection to the compositor, which we can pass onwards to softbuffer::Context to allow it to talk to the compositor too.

This PR updates our examples to use it, which removes the unsafe, and makes it easier for people to follow along (we no longer need the thread_local! hack, so the example code is more localized).

@madsmtm madsmtm added the S - docs Awareness, docs, examples, etc. label Mar 17, 2026
@madsmtm madsmtm force-pushed the madsmtm/softbuffer-fill-remove branch 2 times, most recently from 2f92d98 to c40cdde Compare March 18, 2026 21:40
By using `OwnedDisplayHandle`, which uses reference-counting, instead of
`DisplayHandle<'static>` (where the user has to guarantee that the
Application doesn't outlive the event loop).
@madsmtm madsmtm force-pushed the madsmtm/softbuffer-fill-remove branch from c40cdde to c009698 Compare March 26, 2026 05:37
This is unsound, and makes the examples harder for people to follow.

This is possible nowadays with `OwnedDisplayHandle`.
@madsmtm madsmtm force-pushed the madsmtm/softbuffer-fill-remove branch from c009698 to b33122a Compare March 26, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S - docs Awareness, docs, examples, etc.

Development

Successfully merging this pull request may close these issues.

1 participant