diff --git a/sane/scanner.cpp b/sane/scanner.cpp index 6860cd9..fcc0c02 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -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);