From cd6298168a7180290a376c830e2618b0477c74cd Mon Sep 17 00:00:00 2001 From: yangjiaxuan <171295266@qq.com> Date: Wed, 6 Dec 2023 17:33:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=82=B9=E5=87=BB=E7=BB=A7?= =?UTF-8?q?=E7=BB=AD=E6=89=AB=E6=8F=8F=E4=BC=9A=E9=87=8D=E5=A4=8D=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E8=BF=9B=E5=BA=A6=E6=8C=87=E7=A4=BA=E5=99=A8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9BBUG-814?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sane/scanner.cpp | 55 +++++++++++++++------------------------- twain/twain/huagaods.cpp | 3 ++- 2 files changed, 23 insertions(+), 35 deletions(-) diff --git a/sane/scanner.cpp b/sane/scanner.cpp index 09b5ea7..968a19a 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -1650,45 +1650,32 @@ int scanner::thread_start(void) /*if (indicator_.get() && !IsWindowVisible(indicator_->hwnd())) indicator_->show(true);*/ } - //else if (indicator_.get()) - //{ - // indicator_->notify_scan_over(hg_scanner_err_description(ret), true); - //} else { - // display error message on progress UI, may be closed immediately by APP, so we hide progress UI and call message_box ... - // err_ = ret; -#ifdef START_SCAN_IN_THREAD - if (callback::show_progress_ui && is_bIndicator && ui_notify && !is_in_working_thread_) - { - int ev = SANE_EVENT_WORKING; - - ui_notify(SANE_EVENT_SCAN_FINISHED, (void *)hg_scanner_err_description(ret), ret); - } - else if(!is_in_working_thread_) -#endif - { - 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 (indicator_.get()) - // indicator_->show(false); - 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; + //startʧ°Ü»ò×èÈûʱ¾Í²»ÔÙµ÷Óûص÷֪ͨ BUG-814 + if (ui_notify) + { + ui_notify(SANE_EVENT_WORKING, NULL, 0); + ui_notify(SANE_EVENT_SCAN_FINISHED, (void*)hg_scanner_err_description(ret), ret); + while (is_scanning_) + std::this_thread::sleep_for(std::chrono::milliseconds(3)); } + else 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); + } + + scan_over_ = true; + is_scanning_ = false; } prev_start_result_ = ret; diff --git a/twain/twain/huagaods.cpp b/twain/twain/huagaods.cpp index 27febac..b21b570 100644 --- a/twain/twain/huagaods.cpp +++ b/twain/twain/huagaods.cpp @@ -1,4 +1,4 @@ -#ifdef max +#ifdef max #undef max #endif #ifdef min @@ -3927,6 +3927,7 @@ int huagao_ds::handle_scanner_event(int ev, bool from_event_proc) //} break; case SANE_EVENT_TWAIN_XFER_READY: + load_sane_util::log_info(L"notifyXferReady ...\r\n", 1); notifyXferReady(); break; }