解决跳过空白页不出图报错IO国产只能打开第一台设备的问题

This commit is contained in:
yangjiaxuan 2023-08-18 12:47:18 +08:00
parent 5852323981
commit 7d3fffbb11
3 changed files with 22 additions and 5 deletions

View File

@ -510,7 +510,7 @@ HGResult HGSaneSourceImpl::OpenSelectedDevice(HGWindow parent, class HGSaneDevic
char devName[256] = {0}; char devName[256] = {0};
for (int i = 0; i < devs.size(); ++i) for (int i = 0; i < devs.size(); ++i)
{ {
if (devs[i].id = id) if (devs[i].id == id)
{ {
strcpy(devName, devs[i].name.c_str()); strcpy(devName, devs[i].name.c_str());
m_saneApi.sane_open_api(devs[i].name.c_str(), &handle); m_saneApi.sane_open_api(devs[i].name.c_str(), &handle);
@ -1016,15 +1016,24 @@ void HGAPI HGSaneDeviceImpl::ThreadFunc(HGThread thread, HGPointer param)
} }
else if (SANE_STATUS_EOF == stat2) else if (SANE_STATUS_EOF == stat2)
{ {
if (0 == readSize && p->m_cancelScan) if (0 == readSize)
{ {
free(buffer); free(buffer);
if (NULL != p->m_scanNotify) if (p->m_cancelScan)
p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, (void*)saneAPI.sane_strstatus_api(SANE_STATUS_CANCELLED), (int)SANE_STATUS_CANCELLED); {
if (NULL != p->m_scanNotify)
p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, (void*)saneAPI.sane_strstatus_api(SANE_STATUS_CANCELLED), (int)SANE_STATUS_CANCELLED);
}
else
{
if (NULL != p->m_scanNotify)
p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, NULL, 0);
}
break; break;
} }
if (0 == readSize || readSize != params.bytes_per_line * params.lines) if (readSize != params.bytes_per_line * params.lines)
{ {
free(buffer); free(buffer);
if (NULL != p->m_scanNotify) if (NULL != p->m_scanNotify)

View File

@ -113,3 +113,8 @@ void Dialog_device_select::on_pbtn_cancel_clicked()
m_devId = -1; m_devId = -1;
reject(); reject();
} }
void Dialog_device_select::on_listWidget_itemDoubleClicked(QListWidgetItem *item)
{
on_pbtn_ok_clicked();
}

View File

@ -3,6 +3,7 @@
#include <QDialog> #include <QDialog>
#include "twainui.h" #include "twainui.h"
#include <QListWidgetItem>
namespace Ui { namespace Ui {
class Dialog_device_select; class Dialog_device_select;
@ -26,6 +27,8 @@ private slots:
void on_pbtn_cancel_clicked(); void on_pbtn_cancel_clicked();
void on_listWidget_itemDoubleClicked(QListWidgetItem *item);
private: private:
Ui::Dialog_device_select *ui; Ui::Dialog_device_select *ui;