调整 qt twain 退出状态不对的问题

This commit is contained in:
13038267101 2023-05-08 15:31:24 +08:00
parent 583c545c28
commit 65df84f277
2 changed files with 19 additions and 52 deletions

View File

@ -705,66 +705,27 @@ void scanner::on_ui_event(int uev, void* sender)
{
//wchar_t info[128] = { 0 };
//(info, _countof(info) - 1, L"[CRAZY]%d scanner events stored but APP has no action, we try to trigger it ONCE ...\r\n", ev_cnt_);
//ev_cnt_--;
ev_cnt_;
h(SANE_EVENT_UI_SCAN_COMMAND, evh_param_);
return;
}
}
bool indicator = sender == indicator_.get();
if (uev == SANE_EVENT_SCAN_FINISHED || uev == SANE_EVENT_UI_CLOSE_NORMAL || uev == SANE_EVENT_UI_CLOSE_CANCEL)
{
if (uev == SANE_EVENT_UI_CLOSE_CANCEL)
stop();
if (indicator)
indicator_.reset();
is_scanning_ = false;
if (err_ && setting_.get())
{
return;
}
}
//int(__stdcall * h)(int, void*) = scanner_ev_handler_;
//if (h)
//{
// if (SANE_EVENT_UI_CLOSE_SETTING == uev)
// {
// is_scanning_ = false;
// setting_.reset();
// }
// h(uev, evh_param_);
// return;
//}
//if (prev_start_result_ != SANE_STATUS_GOOD && indicator)
// indicator_.reset();
//else
if (uev == SANE_EVENT_UI_CLOSE_CANCEL || uev == SANE_EVENT_UI_CLOSE_NORMAL || uev == SANE_EVENT_UI_CLOSE_SETTING)
{
//if (uev == SANE_EVENT_UI_SCAN_COMMAND)
//{
// ui_show_progress(NULL);
// start();
// return;
//}
if (/*events_.count() > 5 && !is_ui_wait_img_ &&*/
(uev == SANE_EVENT_UI_CLOSE_CANCEL || uev == SANE_EVENT_UI_CLOSE_NORMAL || uev == SANE_EVENT_UI_CLOSE_SETTING))
{
// events_.clear();
ui_hide();
if(indicator || !indicator_.get())
uev = SANE_EVENT_SCAN_FINISHED;
else
events_.clear();
uev = SANE_EVENT_UI_CLOSE_SETTING;
}
events_.save(uev, sizeof(uev));
ev_cnt_++;
}
@ -2942,6 +2903,7 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_main(HWND parent))
}
COM_API_IMPLEMENT(scanner, bool, ui_show_setting(HWND parent, bool with_scan, bool indicator))
{
is_show_ui_ = with_scan;
if (callback::show_setting_ui)
{
auto ui = [this](ui_result res)
@ -2956,10 +2918,12 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_setting(HWND parent, bool with_scan, bo
break;
case UI_RESULT_CLOSE_NORMAL:
is_show_ui_ = false;
uev = SANE_EVENT_UI_CLOSE_NORMAL;
on_ui_event(uev, (void*)uev);
break;
case UI_RESULT_CLOSE_CANCEL:
is_show_ui_ = false;
uev = SANE_EVENT_UI_CLOSE_CANCEL;
on_ui_event(uev, (void*)uev);
@ -3033,12 +2997,17 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_progress(HWND parent, bool bIndicator))
break;
case UI_RESULT_CLOSE_NORMAL:
uev = SANE_EVENT_UI_CLOSE_NORMAL;
if (!is_show_ui_)
{
on_ui_event(uev, (void*)uev);
}
break;
case UI_RESULT_CLOSE_CANCEL:
uev = SANE_EVENT_UI_CLOSE_CANCEL;
if (!is_show_ui_)
{
on_ui_event(uev, (void*)uev);
}
break;
case UI_RESULT_START_SCAN:
break;
@ -3048,8 +3017,6 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_progress(HWND parent, bool bIndicator))
};
if (callback::show_progress_ui && bIndicator)
{
callback::show_progress_ui(parent, ui_process,&ui_notify);
}
else

View File

@ -63,7 +63,7 @@ class scanner : public ISaneInvoker, virtual public refer
int(__stdcall* scanner_ev_handler_)(int, void*);
void* evh_param_;
HWND app_wnd_; // for MessageBox
bool is_show_ui_;
void transport_config_file(void);
void update_config(void);
void load_config(const wchar_t* file);