Panics · P09 Overlays: a lightbox or tour past its last item closes
This commit is contained in:
1 parent
7af7c409c9
commit
8f00d2eabb
4 files changed
+35
-15
No files matched your search
@@ -96,15 +96,9 @@ impl Lightbox {
|
||||
at: usize,
|
||||
on_close: impl Fn(&mut Window, &mut App) + 'static,
|
||||
) -> Self {
|
||||
let slides: Vec<Slide> = slides.into_iter().collect();
|
||||
assert!(
|
||||
slides.is_empty() || at < slides.len(),
|
||||
"slide {at} is past the last of {}",
|
||||
slides.len()
|
||||
);
|
||||
Self {
|
||||
id: id.into(),
|
||||
slides,
|
||||
slides: slides.into_iter().collect(),
|
||||
at,
|
||||
on_step: None,
|
||||
on_close: Rc::new(on_close),
|
||||
@@ -140,6 +134,14 @@ impl RenderOnce for Lightbox {
|
||||
window.defer(cx, move |window, cx| close(window, cx));
|
||||
return div().into_any_element();
|
||||
}
|
||||
if at >= count {
|
||||
log::error!(
|
||||
"lightbox {:?}: slide {at} of {count} is gone; closing",
|
||||
self.id
|
||||
);
|
||||
window.defer(cx, move |window, cx| close(window, cx));
|
||||
return div().into_any_element();
|
||||
}
|
||||
let step: OnStep = {
|
||||
let (id, on_step) = (self.id.clone(), self.on_step);
|
||||
Rc::new(move |to, window, cx| {
|
||||
|
||||
Reference in new issue
Block a user