Skip to content

Commit

Permalink
Revert "fix: prevent building overlay with stale layout"
Browse files Browse the repository at this point in the history
This reverts commit 3be8f6e.
  • Loading branch information
hecrj committed May 13, 2022
1 parent 3be8f6e commit 4c98de0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 63 deletions.
36 changes: 3 additions & 33 deletions lazy/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,38 +376,6 @@ where
let mut local_messages = Vec::new();
let mut local_shell = Shell::new(&mut local_messages);

if self
.instance
.state
.borrow()
.as_ref()
.and_then(|state| state.borrow_cache().as_ref())
.and_then(|cache| cache.borrow_overlay().as_ref())
.is_none()
{
let component =
self.instance.state.take().unwrap().into_heads().component;

self.instance.state = RefCell::new(Some(
StateBuilder {
component,
message: PhantomData,
cache_builder: |state| {
Some(
CacheBuilder {
element: state.view(),
overlay_builder: |element| {
element.overlay(layout, renderer)
},
}
.build(),
)
},
}
.build(),
));
}

let event_status = self
.with_overlay_mut_maybe(|overlay| {
overlay.on_event(
Expand Down Expand Up @@ -442,7 +410,9 @@ where
Some(
CacheBuilder {
element: state.view(),
overlay_builder: |_| None,
overlay_builder: |element| {
element.overlay(layout, renderer)
},
}
.build(),
)
Expand Down
40 changes: 10 additions & 30 deletions lazy/src/pure/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,35 +415,6 @@ where
let mut local_messages = Vec::new();
let mut local_shell = Shell::new(&mut local_messages);

if self
.overlay
.as_ref()
.and_then(|overlay| overlay.borrow_overlay().as_ref())
.is_none()
{
let overlay = self.overlay.take().unwrap().into_heads();

self.overlay = Some(
OverlayBuilder {
instance: overlay.instance,
instance_ref_builder: |instance| instance.state.borrow(),
tree: overlay.tree,
types: PhantomData,
overlay_builder: |instance, tree| {
instance
.as_ref()
.unwrap()
.borrow_element()
.as_ref()
.unwrap()
.as_widget()
.overlay(&mut tree.children[0], layout, renderer)
},
}
.build(),
);
}

let event_status = self
.with_overlay_mut_maybe(|overlay| {
overlay.on_event(
Expand Down Expand Up @@ -493,7 +464,16 @@ where
instance_ref_builder: |instance| instance.state.borrow(),
tree: overlay.tree,
types: PhantomData,
overlay_builder: |_, _| None,
overlay_builder: |instance, tree| {
instance
.as_ref()
.unwrap()
.borrow_element()
.as_ref()
.unwrap()
.as_widget()
.overlay(&mut tree.children[0], layout, renderer)
},
}
.build(),
);
Expand Down

0 comments on commit 4c98de0

Please sign in to comment.