解决双张保留后如果有无纸等错误状态,一直正在扫描未退出线程
This commit is contained in:
parent
90c021bc64
commit
6b99063ba9
|
@ -489,7 +489,7 @@ scanner::scanner(SCANNERID id) : handle_(NULL), id_(id), ex_id_(EXTENSION_ID_BAS
|
||||||
, dpi_(200), tmp_path_(L""), img_ind_(0)
|
, dpi_(200), tmp_path_(L""), img_ind_(0)
|
||||||
, scanner_name_(L""), cfg_(NULL), is_ui_wait_img_(false), is_scanning_(false)
|
, scanner_name_(L""), cfg_(NULL), is_ui_wait_img_(false), is_scanning_(false)
|
||||||
, scanner_ev_handler_(NULL), evh_param_(NULL), app_wnd_(NULL), user_cancel_(false)
|
, scanner_ev_handler_(NULL), evh_param_(NULL), app_wnd_(NULL), user_cancel_(false)
|
||||||
, max_img_mem_(400), wait_fetch_(60 * 1000), twain_set_(false), ev_cnt_(0), is_bIndicator(false), is_show_setting_(false)
|
, max_img_mem_(400), wait_fetch_(60 * 1000), twain_set_(false), ev_cnt_(0), is_bIndicator(false), is_show_setting_(false), is_in_working_thread_(false)
|
||||||
{
|
{
|
||||||
ui_notify = std::function<void(int, void*, int)>();
|
ui_notify = std::function<void(int, void*, int)>();
|
||||||
|
|
||||||
|
@ -1602,6 +1602,7 @@ int scanner::set_is_multiout(bool enable)
|
||||||
|
|
||||||
int scanner::thread_start(void)
|
int scanner::thread_start(void)
|
||||||
{
|
{
|
||||||
|
is_in_working_thread_ = false;
|
||||||
scan_over_ = false;
|
scan_over_ = false;
|
||||||
double_handle_ = DOUBLE_FEED_NEED_UI;
|
double_handle_ = DOUBLE_FEED_NEED_UI;
|
||||||
|
|
||||||
|
@ -1632,7 +1633,7 @@ int scanner::thread_start(void)
|
||||||
//
|
//
|
||||||
err_ = ret;
|
err_ = ret;
|
||||||
#ifdef START_SCAN_IN_THREAD
|
#ifdef START_SCAN_IN_THREAD
|
||||||
if (callback::show_progress_ui && is_bIndicator && ui_notify)
|
if (callback::show_progress_ui && is_bIndicator && ui_notify && !is_in_working_thread_)
|
||||||
{
|
{
|
||||||
int ev = SANE_EVENT_WORKING;
|
int ev = SANE_EVENT_WORKING;
|
||||||
|
|
||||||
|
@ -1669,7 +1670,41 @@ int scanner::thread_start(void)
|
||||||
|
|
||||||
int scanner::thread_start_after_keep()
|
int scanner::thread_start_after_keep()
|
||||||
{
|
{
|
||||||
|
is_in_working_thread_ = false;
|
||||||
|
|
||||||
int ret = hg_sane_middleware::instance()->start(handle_, NULL);
|
int ret = hg_sane_middleware::instance()->start(handle_, NULL);
|
||||||
|
|
||||||
|
if (ret != SANE_STATUS_GOOD && ret != SCANNER_ERR_DEVICE_DOUBLE_FEEDING)
|
||||||
|
{
|
||||||
|
if (callback::show_progress_ui && is_bIndicator && ui_notify)
|
||||||
|
{
|
||||||
|
int ev = ret;
|
||||||
|
|
||||||
|
if (!is_in_working_thread_)
|
||||||
|
ui_notify(SANE_EVENT_SCAN_FINISHED, (void*)hg_scanner_err_description(ret), ret);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
scan_over_ = true;
|
||||||
|
if (callback::close_ui)
|
||||||
|
callback::close_ui(UI_INDICATOR);
|
||||||
|
|
||||||
|
if (callback::show_messagebox_ui)
|
||||||
|
{
|
||||||
|
callback::show_messagebox_ui(app_wnd_, ret, (void*)hg_scanner_err_description(ret), 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::wstring msg(local_trans::a2u(hg_scanner_err_description(ret), CP_UTF8));
|
||||||
|
if (!IsWindow(app_wnd_))
|
||||||
|
callback::bring_message_box_topmost(local_trans::lang_trans_between_hz936(CONST_STRING_START_FAILED).c_str());
|
||||||
|
MessageBoxW(app_wnd_, msg.c_str(), local_trans::lang_trans_between_hz936(CONST_STRING_START_FAILED).c_str(), MB_OK | MB_ICONERROR);
|
||||||
|
}
|
||||||
|
is_scanning_ = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3610,6 +3645,7 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len)
|
||||||
dlg_indicator* prog = indicator_;
|
dlg_indicator* prog = indicator_;
|
||||||
if (ev_code == SANE_EVENT_WORKING)
|
if (ev_code == SANE_EVENT_WORKING)
|
||||||
{
|
{
|
||||||
|
is_in_working_thread_ = true;
|
||||||
img_ind_ = 0;
|
img_ind_ = 0;
|
||||||
if (prog)
|
if (prog)
|
||||||
prog->notify_working();
|
prog->notify_working();
|
||||||
|
@ -3710,6 +3746,7 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
is_in_working_thread_ = false;
|
||||||
err_ = *len;
|
err_ = *len;
|
||||||
scan_over_ = true;
|
scan_over_ = true;
|
||||||
scan_msg_ = data ? (char*)data : "OK";
|
scan_msg_ = data ? (char*)data : "OK";
|
||||||
|
|
|
@ -86,6 +86,7 @@ class scanner : public ISaneInvoker, virtual public refer
|
||||||
void* evh_param_;
|
void* evh_param_;
|
||||||
HWND app_wnd_; // for MessageBox
|
HWND app_wnd_; // for MessageBox
|
||||||
bool is_show_ui_;
|
bool is_show_ui_;
|
||||||
|
bool is_in_working_thread_;
|
||||||
|
|
||||||
int transfer_id(int id); // transfer fixed SANE option ID to real id, -1 is none
|
int transfer_id(int id); // transfer fixed SANE option ID to real id, -1 is none
|
||||||
void transport_config_file(void);
|
void transport_config_file(void);
|
||||||
|
|
Loading…
Reference in New Issue