解决测试过程中断开usb会出现卡死的问题
This commit is contained in:
parent
ae97584654
commit
2dfc05386d
|
@ -53,6 +53,7 @@ MainWindow::MainWindow(Dialog_logIn::LogInType loginType, const QString &profile
|
|||
|
||||
connect(this, SIGNAL(sane_dev_arrive(QString)), this, SLOT(on_sane_dev_arrive(QString)), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(sane_dev_remove(QString)), this, SLOT(on_sane_dev_remove(QString)), Qt::QueuedConnection);
|
||||
connect(this, &MainWindow::sane_create_interface, this, &MainWindow::on_sane_create_interface, Qt::QueuedConnection);
|
||||
|
||||
if (m_loginType == Dialog_logIn::LogInType_Burn)
|
||||
{
|
||||
|
@ -112,7 +113,7 @@ MainWindow::MainWindow(Dialog_logIn::LogInType loginType, const QString &profile
|
|||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
HGBase_EnterLock(m_lock);
|
||||
//HGBase_EnterLock(m_lock);
|
||||
if (m_top_splitter != nullptr)
|
||||
{
|
||||
while (0 != m_top_splitter->count())
|
||||
|
@ -131,7 +132,7 @@ MainWindow::~MainWindow()
|
|||
}
|
||||
}
|
||||
|
||||
HGBase_LeaveLock(m_lock);
|
||||
//HGBase_LeaveLock(m_lock);
|
||||
|
||||
sane_exit();
|
||||
|
||||
|
@ -254,7 +255,7 @@ bool MainWindow::AddInterface(Form_mainInterface * mainInterface)
|
|||
{
|
||||
assert(nullptr != mainInterface);
|
||||
|
||||
HGBase_EnterLock(m_lock);
|
||||
//HGBase_EnterLock(m_lock);
|
||||
bool ret = false;
|
||||
if (m_top_splitter->count() < 2)
|
||||
{
|
||||
|
@ -266,7 +267,7 @@ bool MainWindow::AddInterface(Form_mainInterface * mainInterface)
|
|||
m_bot_splitter->addWidget(mainInterface);
|
||||
ret = true;
|
||||
}
|
||||
HGBase_LeaveLock(m_lock);
|
||||
//HGBase_LeaveLock(m_lock);
|
||||
|
||||
updateSplitter();
|
||||
return ret;
|
||||
|
@ -275,9 +276,11 @@ bool MainWindow::AddInterface(Form_mainInterface * mainInterface)
|
|||
bool MainWindow::RemoveInterface(Form_mainInterface * mainInterface)
|
||||
{
|
||||
assert(nullptr != mainInterface);
|
||||
HGBase_EnterLock(m_lock);
|
||||
//HGBase_EnterLock(m_lock);
|
||||
delete mainInterface;
|
||||
HGBase_LeaveLock(m_lock);
|
||||
mainInterface = nullptr;
|
||||
m_testingRef = 0;
|
||||
//HGBase_LeaveLock(m_lock);
|
||||
updateSplitter();
|
||||
return true;
|
||||
}
|
||||
|
@ -343,17 +346,13 @@ int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigne
|
|||
|
||||
if (code == SANE_EVENT_IMAGE_OK || code == SANE_EVENT_SCAN_FINISHED || code == SANE_EVENT_ERROR || code == SANE_EVENT_STATUS)
|
||||
{
|
||||
HGBase_EnterLock(p->m_lock);
|
||||
if (p->m_loginType != Dialog_logIn::LogInType_Burn)
|
||||
{
|
||||
Form_mainInterface* mainInterface = p->FindInterface(hdev);
|
||||
if (nullptr != mainInterface)
|
||||
{
|
||||
if (nullptr != mainInterface->getScanner() && nullptr != mainInterface->getScanner()->cb_)
|
||||
mainInterface->getScanner()->cb_(hdev, code, data, len, mainInterface->getScanner());
|
||||
}
|
||||
}
|
||||
HGBase_LeaveLock(p->m_lock);
|
||||
SaneParams *saneParams = new SaneParams;
|
||||
saneParams->hdev = hdev;
|
||||
saneParams->code = code;
|
||||
saneParams->data = data;
|
||||
saneParams->len = len;
|
||||
|
||||
emit p->sane_create_interface(saneParams);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -496,7 +495,7 @@ void MainWindow::on_sane_dev_remove(QString devName)
|
|||
if (mainInterface != nullptr)
|
||||
{
|
||||
mainInterface->setDevDisconnect();
|
||||
if (!mainInterface->isTesting())
|
||||
//if (!mainInterface->isTesting())
|
||||
{
|
||||
RemoveInterface(mainInterface);
|
||||
}
|
||||
|
@ -504,6 +503,24 @@ void MainWindow::on_sane_dev_remove(QString devName)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_sane_create_interface(SaneParams *saneParams)
|
||||
{
|
||||
if (m_loginType != Dialog_logIn::LogInType_Burn)
|
||||
{
|
||||
Form_mainInterface* mainInterface = FindInterface(saneParams->hdev);
|
||||
if (nullptr != mainInterface)
|
||||
{
|
||||
if (nullptr != mainInterface->getScanner() && nullptr != mainInterface->getScanner()->cb_)
|
||||
{
|
||||
mainInterface->getScanner()->cb_(saneParams->hdev, saneParams->code, saneParams->data, saneParams->len, mainInterface->getScanner());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete saneParams;
|
||||
saneParams = nullptr;
|
||||
}
|
||||
|
||||
void MainWindow::on_update_userStatus()
|
||||
{
|
||||
QString tips;
|
||||
|
|
|
@ -46,13 +46,23 @@ private:
|
|||
QString getDevType(SANE_Handle handle);
|
||||
QString getDevFwNum(SANE_Handle handle);
|
||||
|
||||
struct SaneParams
|
||||
{
|
||||
SANE_Handle hdev;
|
||||
int code;
|
||||
void *data;
|
||||
unsigned int *len;
|
||||
};
|
||||
|
||||
signals:
|
||||
void sane_dev_arrive(QString devName);
|
||||
void sane_dev_remove(QString devName);
|
||||
void sane_create_interface(SaneParams *saneParams);
|
||||
|
||||
private slots:
|
||||
void on_sane_dev_arrive(QString devName);
|
||||
void on_sane_dev_remove(QString devName);
|
||||
void on_sane_create_interface(SaneParams *saneParams);
|
||||
void on_update_userStatus();
|
||||
|
||||
private slots:
|
||||
|
|
Loading…
Reference in New Issue