summaryrefslogtreecommitdiffstats
path: root/lazy/src/component.rs
diff options
context:
space:
mode:
authorLibravatar Nick Senger <nicks@lich.io>2022-05-10 17:18:08 -0700
committerLibravatar Nick Senger <nicks@lich.io>2022-05-10 17:23:30 -0700
commit3be8f6e98990f7e8a3af11400bbecaecddda336c (patch)
treed616239a59b6d3a726d5763fa7eeca2beb7aafc1 /lazy/src/component.rs
parentd4ed8afa1ed15486144dc7afee52c09e044a92e0 (diff)
downloadiced-3be8f6e98990f7e8a3af11400bbecaecddda336c.tar.gz
iced-3be8f6e98990f7e8a3af11400bbecaecddda336c.tar.bz2
iced-3be8f6e98990f7e8a3af11400bbecaecddda336c.zip
fix: prevent building overlay with stale layout
Diffstat (limited to 'lazy/src/component.rs')
-rw-r--r--lazy/src/component.rs36
1 files changed, 33 insertions, 3 deletions
diff --git a/lazy/src/component.rs b/lazy/src/component.rs
index 9e5937e9..06392c33 100644
--- a/lazy/src/component.rs
+++ b/lazy/src/component.rs
@@ -376,6 +376,38 @@ 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(
@@ -410,9 +442,7 @@ where
Some(
CacheBuilder {
element: state.view(),
- overlay_builder: |element| {
- element.overlay(layout, renderer)
- },
+ overlay_builder: |_| None,
}
.build(),
)