From a436af8b35dacde89ec97e18134b02acf52f159c Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 27 Oct 2026 12:35:11 +0100 Subject: 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. --- crates/gipfel-web/src/app.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'crates') 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; -- cgit v1.2.3