mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-21 11:26:15 +02:00
fix(store): error instead of panic on invalid rid (#3157)
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"store": patch
|
||||
"store-js": patch
|
||||
---
|
||||
|
||||
Return an error instead of panic when the internally tracked resource id is invalid on creating new stores
|
||||
@@ -197,7 +197,10 @@ impl<R: Runtime> StoreBuilder<R> {
|
||||
let _ = self.app.resources_table().take::<Store<R>>(rid);
|
||||
}
|
||||
} else if let Some(rid) = stores.get(&self.path) {
|
||||
return Ok((self.app.resources_table().get(*rid).unwrap(), *rid));
|
||||
// The resource id we stored can be invalid due to
|
||||
// the resource table getting modified by an external source
|
||||
// (e.g. `App::cleanup_before_exit` > `manager.resources_table.clear()`)
|
||||
return Ok((self.app.resources_table().get(*rid)?, *rid));
|
||||
}
|
||||
|
||||
// if stores.contains_key(&self.path) {
|
||||
|
||||
Reference in New Issue
Block a user