针对讯飞启明扫描完成后TIMER消息重入导致界面卡死问题,在取图流程中忽略该消息。也可以通过外部配置: [twain-app]ignore-msg= && ignore-msg-wp=

This commit is contained in:
gb 2023-12-13 11:38:32 +08:00
parent 85fb296aa9
commit ee19dba608
2 changed files with 45 additions and 2 deletions

View File

@ -552,6 +552,29 @@ scanner::scanner(SCANNERID id) : handle_(NULL), id_(id), ex_id_(EXTENSION_ID_BAS
{ {
wait_fetch_ = mem_limit * 1000; // second to millisecond wait_fetch_ = mem_limit * 1000; // second to millisecond
} }
re_enter_msg_ = GetPrivateProfileIntW(L"twain-app", L"ignore-msg", 0, (cfg_path_ + L"debug.cfg").c_str());
re_enter_msg_wp_ = GetPrivateProfileIntW(L"twain-app", L"ignore-msg-wp", 0, (cfg_path_ + L"debug.cfg").c_str());
if (re_enter_msg_ == 0)
{
wchar_t path[MAX_PATH] = { 0 }, * name = NULL;
GetModuleFileNameW(NULL, path, _countof(path) - 1);
name = wcsrchr(path, L'\\');
if (name++ == NULL)
name = path;
if (wcsicmp(name, L"proScanner.exe") == 0)
{
re_enter_msg_ = WM_TIMER;
re_enter_msg_wp_ = 1;
}
}
if(re_enter_msg_)
{
wchar_t info[128] = { 0 };
swprintf_s(info, _countof(info) - 1, L"Ignore message(0x%x) when get images\r\n", re_enter_msg_);
log_info(info, 1);
}
err_ = open(); err_ = open();
} }
scanner::~scanner() scanner::~scanner()
@ -2839,10 +2862,27 @@ COM_API_IMPLEMENT(scanner, int, get_scanned_images(DWORD milliseconds))
{ {
MSG msg = { 0 }; MSG msg = { 0 };
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
bool block_msg = false;
if (re_enter_msg_ && re_enter_msg_ == msg.message)
{
if (re_enter_msg_wp_)
{
block_msg = re_enter_msg_wp_ == msg.wParam;
}
else
{
block_msg = true;
}
}
if (!block_msg)
{ {
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessageW(&msg); DispatchMessageW(&msg);
} }
}
else else
Sleep(elapse); Sleep(elapse);

View File

@ -57,6 +57,9 @@ class scanner : public ISaneInvoker, virtual public refer
int double_handle_ = DOUBLE_FEED_NEED_UI; // int double_handle_ = DOUBLE_FEED_NEED_UI; //
bool is_bIndicator; bool is_bIndicator;
bool is_show_setting_; bool is_show_setting_;
UINT re_enter_msg_ = 0; // 针对讯飞启明扫描完成后TIMER消息重入导致界面卡死问题在取图流程中忽略该消息。也可以通过外部配置
UINT re_enter_msg_wp_ = 0;
unsigned int img_ind_; unsigned int img_ind_;
std::wstring scanner_name_; std::wstring scanner_name_;
std::wstring tmp_path_; std::wstring tmp_path_;