-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Key/Button::is_pressed are not thread safe #226
Comments
One partial solution to this would to add a dummy &RenderWindow parameter to Key::is_pressed. This should prevent it from being called in another thread than where the RenderWindow lives, because RenderWindow is !Sync. This wouldn't work whenever the user creates multiple RenderWindows though. |
Looks like is_pressed isn't the only misbehaving API. There can be threading related errors for example if you create 2 sf::RenderWindows on 2 different threads. And there is probably more. I don't have any clear plan on how to solve all of these threading issues, so for the time being I just added a warning to the documentation. |
What about adding a
Using this, every RenderWindow has to live in the same thread. This then allows to either:
|
That sounds like it might work. If you'd like you can submit a pull request, but for now I'll try to explore what other thread safety issues we might have. |
At least on X11, it can trigger all kinds of errors to call them from a different thread.
And someone messaged me that it can cause segfaults for them to do so.
The text was updated successfully, but these errors were encountered: