keyfork-qrcode: handle two good scans

This commit is contained in:
Ryan Heywood 2025-05-10 14:42:50 -04:00
parent f63b686e70
commit 2083eb216f
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
1 changed files with 6 additions and 8 deletions

View File

@ -244,22 +244,21 @@ pub fn scan_camera(timeout: Duration, index: usize) -> Result<Option<String>, QR
}
let mut queue = condvar
.wait_while(queue, |queue| {
eprintln!("thread {i} received signal");
queue.images.is_empty() || queue.shutdown
queue.images.is_empty() && !queue.shutdown
})
.expect(bug::bug!(POISONED_MUTEX));
if let Some(image) = queue.images.pop() {
eprintln!("thread {i} received image");
// drop the queue here since this is what's going to take time
drop(queue);
if let Some(content) = scanner.scan_image(image) {
println!("scanned: {content}");
tx.send(content).expect(
bug::bug!("A scanned image could not be sent")
);
eprintln!("scanned: {content}");
if tx.send(content).is_err() {
break;
}
}
}
}
eprintln!("shutting down thread {i}");
});
}
@ -284,7 +283,6 @@ pub fn scan_camera(timeout: Duration, index: usize) -> Result<Option<String>, QR
.expect(bug::bug!(POISONED_MUTEX))
.images
.push(image);
eprintln!("notifying any thread");
arced.1.notify_one();
}