We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fdaf48f commit e349dfeCopy full SHA for e349dfe
.changes/fix-resource-id.md
@@ -0,0 +1,5 @@
1
+---
2
+'tauri': patch:bug
3
4
+
5
+Fixed a panic caused by an assert when the resource random id has been used already.
crates/tauri/src/resources/mod.rs
@@ -111,7 +111,11 @@ impl ResourceTable {
111
///
112
/// Returns a unique resource ID, which acts as a key for this resource.
113
pub fn add_arc_dyn(&mut self, resource: Arc<dyn Resource>) -> ResourceId {
114
- let rid = Self::new_random_rid();
+ let mut rid = Self::new_random_rid();
115
+ while self.index.contains_key(&rid) {
116
+ rid = Self::new_random_rid();
117
+ }
118
119
let removed_resource = self.index.insert(rid, resource);
120
assert!(removed_resource.is_none());
121
rid
0 commit comments