Fix overlay
implementation for Lazy
widget
#1644
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1583
Currently the
Lazy
widget iniced_lazy
is broken because we assume we canget_mut
anRc
which is not unique - both the element & widget tree hold references to this data.Since we now need a mutable reference to self in
overlay
to support operations, the compiler will prevent us from producing an overlay with a mutable reference to the same element that is being held by theLazy
& its widget tree node. As a workaround, I've temporarily removed the element from the references held on theLazy
& in the widget tree while theOverlay
is in use, and restored it during the overlay'sdrop
. Note that this will break if any widget methods from the parent widget are invoked prior to the overlay being dropped. CurrentlyUserInterface::update
is written such that this doesn't happen, but I'm not sure if it's necessarily guaranteed by Iced.I've also added pick_lists to each item in the
Lazy
example to demonstrate that the overlays are working properly.