Skip to content

fix: Make the test focus event handler thread-safe again#306

Merged
DataTriny merged 1 commit intomainfrom
fix-test-focus-event-handler
Nov 4, 2023
Merged

fix: Make the test focus event handler thread-safe again#306
DataTriny merged 1 commit intomainfrom
fix-test-focus-event-handler

Conversation

@mwcampbell
Copy link
Contributor

I realized that the recent switch from Arc to Rc in this event handler was incorrect, because the event handler is in fact called from a different thread from the one on which it was created. To address the original clippy warning in the safest way possible, I created a new wrapper struct, SendableUiaElement, that implements Send. The compiler can automatically implement Send and Sync on ReceivedFocusEvent from there. I also added a static assertion that Send and Sync are implemented on FocusEventHandler.

Copy link
Member

@DataTriny DataTriny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newtype struct really make things clearer.

@DataTriny DataTriny merged commit bb479c6 into main Nov 4, 2023
@DataTriny DataTriny deleted the fix-test-focus-event-handler branch November 4, 2023 15:12
@mwcampbell mwcampbell mentioned this pull request Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants