-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix(win32): Only return win handle on OK thread
On Windows, it is generally unsafe to use the HWND outside of the thread that it originates from. In reality, the HWND is an index into a thread-local table, so using it outside of the GUI thread can result in another window being used instead, following by code unsoundness. This is why the WindowHandle type is !Send. However, Window is Send and Sync, which means we have to account for this. Thus far the best solution seems to be to check if we are not in the GUI thread. If we aren't, refuse the return the window handle. For users who want to ensure the safety themselves, the unsafe API was added. Signed-off-by: John Nunley <[email protected]>
- Loading branch information
Showing
3 changed files
with
169 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters