summaryrefslogtreecommitdiff
path: root/crates/wipfel/src/app.rs
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-10-28 10:46:31 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-10-28 10:46:31 +0100
commitfe75cd82d6f4f4ecca9c7cd97d9cdfbae646dcff (patch)
tree2880f71c714abbe6f542fc7a9d223835b7cd9544 /crates/wipfel/src/app.rs
parentd91f4022a48fb2468f307026b44cb4555eade7a4 (diff)
web: fix panic when loading an alternative hill database
The load result was matched on while the scrutinee's borrow_mut() was still alive; the Ok arm called pan.borrow() again, which panics (and traps the whole wasm module, hanging the app). End the borrow before the match.
Diffstat (limited to 'crates/wipfel/src/app.rs')
-rw-r--r--crates/wipfel/src/app.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/crates/wipfel/src/app.rs b/crates/wipfel/src/app.rs
index 4194789..71cd168 100644
--- a/crates/wipfel/src/app.rs
+++ b/crates/wipfel/src/app.rs
@@ -550,7 +550,11 @@ pub fn app() -> Html {
},
_ => bytes,
};
- match pan.borrow_mut().load_data_from_bytes(&raw) {
+ // NOTE: the borrow must end before the match arm,
+ // which calls pan.borrow() itself (nested borrow
+ // would panic and trap the whole wasm module)
+ let res = pan.borrow_mut().load_data_from_bytes(&raw);
+ match res {
Ok(()) => {
markers.set(Vec::new());
track.set(Vec::new());