From 4c8691bb4e2ca63ba472a00db4c63f1d8bafd313 Mon Sep 17 00:00:00 2001 From: yangjiaxuan <171295266@qq.com> Date: Mon, 19 Aug 2024 15:27:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=AF=BC=E5=87=BA=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98,BUG-1183?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scanner2/device_user.cpp | 20 ++++++++++++++++++++ app/scanner2/mainwindow.cpp | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/app/scanner2/device_user.cpp b/app/scanner2/device_user.cpp index 551dea86..0117e42d 100644 --- a/app/scanner2/device_user.cpp +++ b/app/scanner2/device_user.cpp @@ -129,6 +129,11 @@ HGResult DeviceUser::ClearRollerCount() QString DeviceUser::GetDriverLog() { QString fileName = QFileDialog::getSaveFileName(m_wnd, tr("Select log file path"), ".", tr("text(*.txt)")); + if (fileName.isEmpty()) + { + return "NULL"; + } + std::string f = getStdFileName(fileName).toLocal8Bit().data(); HGResult ret = HGTwain_GetDSDriverLog(m_twainDS, f.c_str()); if (ret == HGBASE_ERR_OK) @@ -145,6 +150,11 @@ HGResult DeviceUser::ClearDriverLog() QString DeviceUser::GetDeviceLog() { QString fileName = QFileDialog::getSaveFileName(m_wnd, tr("Select log file path"), ".", tr("text(*.txt)")); + if (fileName.isEmpty()) + { + return "NULL"; + } + std::string f = getStdFileName(fileName).toLocal8Bit().data(); HGResult ret = HGTwain_GetDSDeviceLog(m_twainDS, f.c_str()); if (ret == HGBASE_ERR_OK) @@ -344,6 +354,11 @@ int DeviceUser::GetDeviceRollerLife() QString DeviceUser::GetDriverLog() { QString fileName = QFileDialog::getSaveFileName(m_wnd, tr("Select log file path"), ".", tr("text(*.txt)")); + if (fileName.isEmpty()) + { + return "NULL"; + } + std::string f = getStdFileName(fileName).toLocal8Bit().data(); HGResult ret = HGSane_GetDriverLog(m_saneDev, f.c_str()); if (ret == HGBASE_ERR_OK) @@ -360,6 +375,11 @@ HGResult DeviceUser::ClearDriverLog() QString DeviceUser::GetDeviceLog() { QString fileName = QFileDialog::getSaveFileName(m_wnd, tr("Select log file path"), ".", tr("text(*.txt)")); + if (fileName.isEmpty()) + { + return "NULL"; + } + std::string f = getStdFileName(fileName).toLocal8Bit().data(); HGResult ret = HGSane_GetDeviceLog(m_saneDev, f.c_str()); if (ret == HGBASE_ERR_OK) diff --git a/app/scanner2/mainwindow.cpp b/app/scanner2/mainwindow.cpp index 219f9470..82305c47 100644 --- a/app/scanner2/mainwindow.cpp +++ b/app/scanner2/mainwindow.cpp @@ -4902,6 +4902,11 @@ void MainWindow::on_act_driver_log_triggered() if (driverLogPath == "Fail") { QMessageBox::information(this, tr("tips"), tr("The device does not support this operation")); + return; + } + else if (driverLogPath == "NULL") + { + return; } QDesktopServices::openUrl(QUrl::fromLocalFile(driverLogPath)); } @@ -4919,6 +4924,10 @@ void MainWindow::on_act_device_log_triggered() { QMessageBox::information(this, tr("tips"), tr("The device does not support this operation")); } + else if (deviceLogPath == "NULL") + { + return; + } QDesktopServices::openUrl(QUrl::fromLocalFile(deviceLogPath)); }