-
Notifications
You must be signed in to change notification settings - Fork 73
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
Creating controls is unsound #54
Comments
It would perhaps be useful to maintain a hashmap within each of these container controls with each component, which the user could name. This is kind of problematic because we have to decide:
|
by "creating controls is unsound", what exactly do you mean? can you give an example? |
When you make a control, if you don't add as a node in a tree whose root is ultimately a Window or other appropriate control prior to UI handle deinit, the process will abort without unwinding, which is (afaik) not sound. |
Oh, you mean, if you ::new() a control and don't add it to something else,
everything freaks out and crashes? how long does it take to do that? does
it happen on the next repaint or something like that?
…On Sat, Dec 22, 2018 at 10:34 PM Leo Tindall ***@***.***> wrote:
When you make a control, if you don't add as a node in a tree whose root
is ultimately a Window or other appropriate control, the process will abort
without unwinding, which is (afaik) not sound.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/LeoTindall/libui-rs/issues/54#issuecomment-449613791>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ATM34XnmbuNA9SMb11o_Kns2xKDSy5yIks5u7wfTgaJpZM4ZXouk>
.
|
Aborting in itself is safe and sound if done deliberately (eg. by a failed assertion) but not if it happens as a result of undefined behaviour (on the Rust or C side). Of course aborting is still suboptimal in general and is better avoided. |
I think the solution is to implement a trait for containers (HorizontalBox, VerticalBox, Window, Grid, etc) which provides functions to create new controls as children, thus never allowing controls to exist outside of the tree. This seems like a nicer API anyway, to me. |
Alternatively, controls could be created "lazily", such that they are not actually created until attached to a node. |
If we do make an API whereby each container has methods to create its children, whether we do so lazily or eagerly, we could also place a |
This discussion is potentially relevant to #92 |
Creating controls is unsound at the moment. libui enforces a tree structure. We should enforce it in the API.
I would like to do this by creating a trait which permits adding a control, and implementing it on all containers (like windows and grids and boxes).
The question is, should we have individual methods for each control:
or should we have an enum with all the controls?
The text was updated successfully, but these errors were encountered: