修复设置界面启动扫描时,进度界面显示问题

This commit is contained in:
gb 2022-07-28 09:57:26 +08:00
parent 9a70b24d00
commit 7b5a581049
3 changed files with 10 additions and 7 deletions

View File

@ -699,16 +699,15 @@ int usb_device::set_timeout(unsigned milliseconds)
} }
int usb_device::transfer_bulk(unsigned endpoint, unsigned char* data, int* length, unsigned int timeout) int usb_device::transfer_bulk(unsigned endpoint, unsigned char* data, int* length, unsigned int timeout)
{ {
typedef BOOL(WINAPI* file_io)(HANDLE, LPVOID, DWORD, LPDWORD, LPOVERLAPPED);
int ret = LIBUSB_ERROR_NOT_SUPPORTED; int ret = LIBUSB_ERROR_NOT_SUPPORTED;
HANDLE h = find_pipe(endpoint, USBSCAN_PIPE_BULK); HANDLE h = find_pipe(endpoint, USBSCAN_PIPE_BULK);
file_io fio = (endpoint & BULKIN_FLAG) ? ReadFile : (file_io)WriteFile;
if (h) if (h)
{ {
ovl_cls *oc = ovl_mgr_.get_ovl(); ovl_cls *oc = ovl_mgr_.get_ovl();
DWORD io = 0; DWORD io = 0;
BOOL result = fio(h, data, *length, oc->io_bytes(), oc->over_lapped()); BOOL result = (endpoint & BULKIN_FLAG) ? ReadFile(h, data, *length, oc->io_bytes(), oc->over_lapped())
: WriteFile(h, data, *length, oc->io_bytes(), oc->over_lapped());
if (result) if (result)
{ {
@ -723,8 +722,8 @@ int usb_device::transfer_bulk(unsigned endpoint, unsigned char* data, int* lengt
{ {
if (WaitForSingleObject(oc->over_lapped()->hEvent, timeout) == WAIT_OBJECT_0) if (WaitForSingleObject(oc->over_lapped()->hEvent, timeout) == WAIT_OBJECT_0)
{ {
GetOverlappedResult(h, oc->over_lapped(), &io, FALSE); GetOverlappedResult(h, oc->over_lapped(), oc->io_bytes(), FALSE);
*length = io; *length = *oc->io_bytes();
ret = LIBUSB_SUCCESS; ret = LIBUSB_SUCCESS;
} }
else else
@ -808,8 +807,8 @@ int usb_device::transfer_interrupt(unsigned endpoint, unsigned char* data, int*
{ {
if (WaitForSingleObject(oc->over_lapped()->hEvent, timeout) == WAIT_OBJECT_0) if (WaitForSingleObject(oc->over_lapped()->hEvent, timeout) == WAIT_OBJECT_0)
{ {
GetOverlappedResult(h, oc->over_lapped(), &io, FALSE); GetOverlappedResult(h, oc->over_lapped(), oc->io_bytes(), FALSE);
*length = io; *length = *oc->io_bytes();
ret = LIBUSB_SUCCESS; ret = LIBUSB_SUCCESS;
} }
else else

View File

@ -2005,6 +2005,9 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_setting(HWND parent, bool with_scan, bo
} }
COM_API_IMPLEMENT(scanner, bool, ui_show_progress(HWND parent)) COM_API_IMPLEMENT(scanner, bool, ui_show_progress(HWND parent))
{ {
if(setting_.get() && IsWindowVisible(setting_->hwnd()))
parent = setting_->hwnd();
indicator_.reset(new dlg_indicator(parent)); indicator_.reset(new dlg_indicator(parent));
indicator_->set_ui_event_notify(&scanner::ui_callback, this); indicator_->set_ui_event_notify(&scanner::ui_callback, this);
indicator_->show(true); indicator_->show(true);

View File

@ -725,6 +725,7 @@ Result huagao_ds::eventProcess(const Identity&, Event& event)
notifyCloseOk(); notifyCloseOk();
break; break;
case SANE_EVENT_UI_SCAN_COMMAND: case SANE_EVENT_UI_SCAN_COMMAND:
scanner_->ui_show_progress(NULL);
scanner_->start(); scanner_->start();
break; break;
} }