1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 06:40:06 -04:00

[egui_web] Prevent event handlers from running if code has panicked (#1306)

Closes: #1290

Fix panic reported by @Titaniumtown
See https://github.com/emilk/egui/pull/1306#issuecomment-1060775376
This commit is contained in:
Zachary Kohnen
2022-03-10 08:13:32 +01:00
committed by GitHub
parent 30399bf6ff
commit 5d950e1c15
5 changed files with 324 additions and 257 deletions

View File

@@ -1,6 +1,6 @@
//! Simple plotting library.
use std::{cell::RefCell, ops::RangeInclusive, rc::Rc};
use std::{cell::Cell, ops::RangeInclusive, rc::Rc};
use crate::*;
use epaint::ahash::AHashSet;
@@ -92,7 +92,7 @@ impl PlotMemory {
pub struct LinkedAxisGroup {
pub(crate) link_x: bool,
pub(crate) link_y: bool,
pub(crate) bounds: Rc<RefCell<Option<PlotBounds>>>,
pub(crate) bounds: Rc<Cell<Option<PlotBounds>>>,
}
impl LinkedAxisGroup {
@@ -100,7 +100,7 @@ impl LinkedAxisGroup {
Self {
link_x,
link_y,
bounds: Rc::new(RefCell::new(None)),
bounds: Rc::new(Cell::new(None)),
}
}
@@ -132,11 +132,11 @@ impl LinkedAxisGroup {
}
fn get(&self) -> Option<PlotBounds> {
*self.bounds.borrow()
self.bounds.get()
}
fn set(&self, bounds: PlotBounds) {
*self.bounds.borrow_mut() = Some(bounds);
self.bounds.set(Some(bounds));
}
}