Fix deadlock in test

The test held a read lock on SETTINGS while trying to write to it. As
both happened on the same thread, that went wrong and caused a deadlock.
macos-click-through
MultisampledNight 3 years ago
parent 8dbd21fef7
commit fcbb2722f1
No known key found for this signature in database
GPG Key ID: 02B1BAF6A675FF9B

@ -194,21 +194,26 @@ mod tests {
let vt2 = TypeId::of::<f32>(); let vt2 = TypeId::of::<f32>();
let v3: u32 = 2; let v3: u32 = 2;
{
settings.set(&v1); settings.set(&v1);
let values = settings.settings.read(); let values = settings.settings.read();
let r1 = values.get(&vt1).unwrap().downcast_ref::<u32>().unwrap(); let r1 = values.get(&vt1).unwrap().downcast_ref::<u32>().unwrap();
assert_eq!(v1, *r1); assert_eq!(v1, *r1);
}
{
settings.set(&v2); settings.set(&v2);
settings.set(&v3); settings.set(&v3);
let values = settings.settings.read();
let r2 = values.get(&vt1).unwrap().downcast_ref::<u32>().unwrap(); let r2 = values.get(&vt1).unwrap().downcast_ref::<u32>().unwrap();
let r3 = values.get(&vt2).unwrap().downcast_ref::<f32>().unwrap(); let r3 = values.get(&vt2).unwrap().downcast_ref::<f32>().unwrap();
assert_eq!(v3, *r2); assert_eq!(v3, *r2);
assert_eq!(v2, *r3); assert_eq!(v2, *r3);
} }
}
#[test] #[test]
fn test_get() { fn test_get() {

Loading…
Cancel
Save