fix: 修复ocr程序崩溃问题
Description: 修复ocr程序崩溃问题,添加退出标志 Log: 与程序崩溃有关 Change-Id: I0388af1ad4b5555263beaac0584325e468bbb611
This commit is contained in:
parent
d106fb94cd
commit
887a3a3e0d
@ -39,6 +39,8 @@ MainWidget::MainWidget(QWidget *parent) :
|
|||||||
|
|
||||||
MainWidget::~MainWidget()
|
MainWidget::~MainWidget()
|
||||||
{
|
{
|
||||||
|
//程序即将结束,线程标志结束
|
||||||
|
m_isEndThread = 0;
|
||||||
// m_mainGridLayout->addLayout(m_buttonHorizontalLayout, 1, 0, 1, 1);
|
// m_mainGridLayout->addLayout(m_buttonHorizontalLayout, 1, 0, 1, 1);
|
||||||
if (m_mainGridLayout && m_buttonHorizontalLayout) {
|
if (m_mainGridLayout && m_buttonHorizontalLayout) {
|
||||||
m_mainGridLayout->removeItem(m_buttonHorizontalLayout);
|
m_mainGridLayout->removeItem(m_buttonHorizontalLayout);
|
||||||
@ -384,7 +386,10 @@ void MainWidget::openImage(const QImage &img, const QString &name)
|
|||||||
m_loadImagethread = QThread::create([ = ]() {
|
m_loadImagethread = QThread::create([ = ]() {
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
m_result = TessOcrUtils::instance()->getRecogitionResult(m_currentImg, ResultType::RESULT_STRING);
|
m_result = TessOcrUtils::instance()->getRecogitionResult(m_currentImg, ResultType::RESULT_STRING);
|
||||||
emit sigResult(m_result.result);
|
//判断程序是否退出
|
||||||
|
if (1 == m_isEndThread) {
|
||||||
|
emit sigResult(m_result.result);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
connect(m_loadImagethread, &QThread::finished, m_loadImagethread, &QObject::deleteLater);
|
connect(m_loadImagethread, &QThread::finished, m_loadImagethread, &QObject::deleteLater);
|
||||||
|
@ -102,6 +102,7 @@ private:
|
|||||||
QShortcut *m_scAddView = nullptr;
|
QShortcut *m_scAddView = nullptr;
|
||||||
QShortcut *m_scReduceView = nullptr;
|
QShortcut *m_scReduceView = nullptr;
|
||||||
|
|
||||||
|
int m_isEndThread = 1;
|
||||||
signals:
|
signals:
|
||||||
void sigResult(const QString &);
|
void sigResult(const QString &);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user