add time-out control for APP image fetching in scan_done

This commit is contained in:
gb 2023-11-30 09:16:13 +08:00
parent c5b71eb78f
commit e7cd546afb
1 changed files with 19 additions and 2 deletions

View File

@ -807,8 +807,25 @@ void scanner::scan_done(void)
{
std::string msg(scan_msg_);
while (images_.count())
std::this_thread::sleep_for(std::chrono::milliseconds(5));
// avoid APP do not fetch image ... - 2023-11-30
if (err_ != SCANNER_ERR_USER_CANCELED)
{
int cnt = images_.count(),
wait_total = 1000,
wait_unit = 5,
wait = 0;
while (cnt)
{
std::this_thread::sleep_for(std::chrono::milliseconds(wait_unit));
wait++;
if (wait >= wait_total / wait_unit)
break;
else if (cnt != images_.count())
wait = 0;
cnt = images_.count();
}
}
if (indicator_)
indicator_->notify_scan_over(&msg[0], err_ != SCANNER_ERR_OK);