解决点击取消扫描后取法取消的问题
This commit is contained in:
parent
2f7157c238
commit
a3abedfaa3
|
@ -644,6 +644,7 @@ HGSaneDeviceImpl::HGSaneDeviceImpl(HGSaneSourceImpl* sourceImpl)
|
||||||
m_imageParam = NULL;
|
m_imageParam = NULL;
|
||||||
m_stopThread = HGFALSE;
|
m_stopThread = HGFALSE;
|
||||||
m_thread = NULL;
|
m_thread = NULL;
|
||||||
|
m_cancelScan = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HGSaneDeviceImpl::~HGSaneDeviceImpl()
|
HGSaneDeviceImpl::~HGSaneDeviceImpl()
|
||||||
|
@ -871,6 +872,7 @@ HGResult HGSaneDeviceImpl::Start(HGWindow parent, HGSane_DeviceEventFunc eventFu
|
||||||
GetScanCount(&m_oldScanCount);
|
GetScanCount(&m_oldScanCount);
|
||||||
|
|
||||||
m_stopThread = HGFALSE;
|
m_stopThread = HGFALSE;
|
||||||
|
m_cancelScan = false;
|
||||||
HGBase_OpenThread(ThreadFunc, this, &m_thread);
|
HGBase_OpenThread(ThreadFunc, this, &m_thread);
|
||||||
return HGBASE_ERR_OK;
|
return HGBASE_ERR_OK;
|
||||||
}
|
}
|
||||||
|
@ -912,6 +914,7 @@ HGResult HGSaneDeviceImpl::StartWithSingleScan(HGWindow parent, HGSane_DeviceEve
|
||||||
SetScanCount(1);
|
SetScanCount(1);
|
||||||
|
|
||||||
m_stopThread = HGFALSE;
|
m_stopThread = HGFALSE;
|
||||||
|
m_cancelScan = false;
|
||||||
HGBase_OpenThread(ThreadFunc, this, &m_thread);
|
HGBase_OpenThread(ThreadFunc, this, &m_thread);
|
||||||
return HGBASE_ERR_OK;
|
return HGBASE_ERR_OK;
|
||||||
}
|
}
|
||||||
|
@ -941,6 +944,7 @@ void HGSaneDeviceImpl::UIResultCallback(ui_result result)
|
||||||
{
|
{
|
||||||
if (NULL != m_curDevice->m_thread)
|
if (NULL != m_curDevice->m_thread)
|
||||||
{
|
{
|
||||||
|
m_curDevice->m_cancelScan = true;
|
||||||
m_curDevice->m_sourceImpl->m_saneApi.sane_cancel_api(m_curDevice->m_devHandle);
|
m_curDevice->m_sourceImpl->m_saneApi.sane_cancel_api(m_curDevice->m_devHandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1010,6 +1014,14 @@ 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)
|
||||||
|
{
|
||||||
|
free(buffer);
|
||||||
|
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);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (0 == readSize || readSize != params.bytes_per_line * params.lines)
|
if (0 == readSize || readSize != params.bytes_per_line * params.lines)
|
||||||
{
|
{
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
@ -1060,6 +1072,8 @@ void HGAPI HGSaneDeviceImpl::ThreadFunc(HGThread thread, HGPointer param)
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
bufferSize = 0;
|
bufferSize = 0;
|
||||||
|
|
||||||
|
if (!p->m_cancelScan)
|
||||||
|
{
|
||||||
SANE_Status stat3 = saneAPI.sane_start_api(p->m_devHandle);
|
SANE_Status stat3 = saneAPI.sane_start_api(p->m_devHandle);
|
||||||
if (SANE_STATUS_NO_DOCS == stat3)
|
if (SANE_STATUS_NO_DOCS == stat3)
|
||||||
{
|
{
|
||||||
|
@ -1074,6 +1088,7 @@ void HGAPI HGSaneDeviceImpl::ThreadFunc(HGThread thread, HGPointer param)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HGResult HGSaneDeviceImpl::SetValueInt32(HGUInt optionId, HGInt value)
|
HGResult HGSaneDeviceImpl::SetValueInt32(HGUInt optionId, HGInt value)
|
||||||
|
|
|
@ -120,6 +120,7 @@ private:
|
||||||
HGInt m_oldScanCount;
|
HGInt m_oldScanCount;
|
||||||
volatile HGBool m_stopThread;
|
volatile HGBool m_stopThread;
|
||||||
HGThread m_thread;
|
HGThread m_thread;
|
||||||
|
volatile bool m_cancelScan;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __HGSANEIMPL_HPP__ */
|
#endif /* __HGSANEIMPL_HPP__ */
|
||||||
|
|
Loading…
Reference in New Issue