Skip to content
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

Make set_value and get_value threadsafe #7

Open
jdranczewski opened this issue Dec 17, 2024 · 2 comments
Open

Make set_value and get_value threadsafe #7

jdranczewski opened this issue Dec 17, 2024 · 2 comments

Comments

@jdranczewski
Copy link
Owner

Generally functions called outside of the main Qt thread should not manipulate the GUI, instead relying on Signals to change things.

Currently setAutoFillBackground and _input_set_value are used in set_value and get_value of the BaseParam object, which manipulate the GUI directly. This can cause the entire kernel to crash sometimes.

https://doc.qt.io/qt-5/qt.html#ConnectionType-enum - the default Signal connection type is Auto, which means emitting a signal is equivalent to calling a function directly when in the main thread, but uses a queue system when emitted from a different thread. Using Signals we can thus make set_value and get_value safe to use in the main thread and in Workers.

Note that we can't guarantee the user's setters and getters will be threadsafe, but these shouldn't in general have to manipulate the GUI themselves (for that we have the changed Signal).

@jdranczewski
Copy link
Owner Author

Related TODO: colour param red on set_value - currently that only happens on input field change, but we block that Signal when the change is a result of set_value. This is not visible if the UI freezes when set_value is called, but if puzzle.process_events() is called or the set_value happens in a thread, it would be good to make the visual indication happen.

@jdranczewski
Copy link
Owner Author

A way to trigger threaded calls to set_ and get_value from the GUI could be a good feature too

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

No branches or pull requests

1 participant