diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-10-27 12:35:11 +0100 |
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-10-27 12:35:11 +0100 |
| commit | a436af8b35dacde89ec97e18134b02acf52f159c (patch) | |
| tree | 9562d5d8e6091aa1f9e5fc05da0ace2fc7f3200c /crates/gipfel-web/src/app.rs | |
| parent | 8431ea2ac57d64a98ac79e302934c3edf9bf3e55 (diff) | |
web: fix RefCell double-borrow panic in click fast path
`if let Some(idx) = nearest_hill(&pan.borrow(), ...)` keeps the
immutable borrow alive through the whole if-let block (temporary
lifetime in the scrutinee). Marking a peak from that path called
do_refit -> borrow_mut() -> panic, which aborted the wasm instance and
froze all further interaction (no marker removal, no drag refit).
Scope the borrow to its own block.
Diffstat (limited to 'crates/gipfel-web/src/app.rs')
| -rw-r--r-- | crates/gipfel-web/src/app.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/gipfel-web/src/app.rs b/crates/gipfel-web/src/app.rs index 23126e9..e4fd435 100644 --- a/crates/gipfel-web/src/app.rs +++ b/crates/gipfel-web/src/app.rs @@ -558,7 +558,12 @@ pub fn app() -> Html { Callback::from(move |(ix, iy): (f64, f64)| { let scale = view.scale; // unambiguous click right on a peak: mark directly - if let Some(idx) = markers::nearest_hill(&pan.borrow(), ix, iy, 10.0 / scale) { + // (borrow must be released before mark -> do_refit!) + let near = { + let p = pan.borrow(); + markers::nearest_hill(&p, ix, iy, 10.0 / scale) + }; + if let Some(idx) = near { find_peak.set(None); mark.emit((idx, ix, iy)); return; |
