调整utf8 和 close关闭导致崩溃

This commit is contained in:
13038267101 2023-01-16 16:03:14 +08:00
parent 39e794d674
commit 4aaa7742c4
3 changed files with 27 additions and 24 deletions

View File

@ -156,7 +156,8 @@ hg_scanner::hg_scanner(ScannerSerial serial
, dump_usb_path_(""),is_kernelsnap_211209_(false), pid_(0), dump_img_(&hg_scanner::dump_image_empty), is_kernelsnap_220830_(false),is_kernelsnap3288_221106_(false)
, is_kernelsnap_221027_(false), memory_size_(2000/*USB+JPEG压缩及图像处理图队列总共1GB*/), isx86_Advan_(true), stop_fatal_(SCANNER_ERR_OK), is_auto_paper_scan(false)
, size_check(false), save_sleeptime_type_(false), is_kernelsnap_devsislock(false), is_checksum_strat_scan(false), is_cis_image(false)
, is_dpi_color_check(false),save_dpi_color_check_val(0.0f), is_auto_falt(false)
, is_dpi_color_check(false),save_dpi_color_check_val(0.0f), is_auto_falt(false),HGVersion_mgr_(NULL), HGVersion_Init_(NULL)
, HGVersion_Islock_(NULL), HGVersion_Postlog_(NULL), HGVersion_Free_(NULL)
{
#if !defined(_WIN32) && !defined(_WIN64) &&defined(x86_64)
isx86_Advan_ = false;
@ -234,8 +235,10 @@ hg_scanner::hg_scanner(ScannerSerial serial
hg_scanner::~hg_scanner()
{
close(true);
hg_version_free_handle();
if (pid_ == 0x239)
{
hg_version_free_handle();
}
if (thread_usb_read_.get() && thread_usb_read_->joinable())
thread_usb_read_->join();
if (thread_img_handle_.get() && thread_img_handle_->joinable())
@ -948,17 +951,15 @@ void hg_scanner::thread_handle_image_process(void)
{
try
{
if (ImagePrc_pHandle_)
{
image_process(tiny_buffer);
}
else
if (!ImagePrc_pHandle_)
{
VLOG_MINI_1(LOG_LEVEL_FATAL, "Get Image Process is NULL pid is %d.\n",pid_);
stop_fatal_ = SCANNER_ERR_INSUFFICIENT_MEMORY;
stop();
break;
}
image_process(tiny_buffer);
}
catch (const std::exception& e)
{
@ -2881,17 +2882,17 @@ int hg_scanner::set_setting(const char* name, void* data, int len)
type = *((bool*)data) ? "true" : "false";
}
if (notify_setting_result_)
/*if (notify_setting_result_)
{
name.insert(0, "\350\256\276\347\275\256 \"");
name += "\" \345\200\274\344\270\272\"";
name += type + "\" \346\210\220\345\212\237\343\200\202";
notify_ui_working_status(name.c_str());
}
}*/
}
else if (notify_setting_result_)
{
std::string n("");
/*std::string n("");
if (setting_jsn_.contains(real_n))
{
setting_jsn_.at(real_n).at("title").get_to(n);
@ -2900,7 +2901,7 @@ int hg_scanner::set_setting(const char* name, void* data, int len)
n = std::string("\350\256\276\347\275\256\351\241\271") + real_n;
n.insert(0, "\350\256\276\347\275\256 \"");
n += std::string("\" \345\200\274\345\244\261\350\264\245: ") + hg_scanner_err_name(ret);
notify_ui_working_status(n.c_str());
notify_ui_working_status(n.c_str());*/
}
return ret;

View File

@ -949,7 +949,7 @@ void hg_scanner_239::thread_correction(void)
if (sw.elapsed_s() == 60)
{
status_ = ret;
notify_ui_working_status(" \350\256\276\345\244\207\346\240\241\346\255\243\350\266\205\346\227\266", SANE_EVENT_ERROR, ret); // 通信超时
notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_FAIL_OUTTIME, SANE_EVENT_ERROR, ret); // 通信超时
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "设备校正超时 '%s'\n", hg_scanner_err_name(status_));
break;
}
@ -1004,23 +1004,24 @@ void hg_scanner_239::thread_get_dves_image(void)
ret = io_->read_interrupt(buf, &size);
io_->set_timeout(1000);
}
if (ret == SCANNER_ERR_TIMEOUT)
{
if (img_conf_.resolution_dst == 600.0 && ++to_cnt > 50 && !is_auto_paper_scan)
{
status_ = ret;
notify_ui_working_status("\351\200\232\344\277\241\350\266\205\346\227\266", SANE_EVENT_ERROR, ret); // 通信超时
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "600dpi '%s'\n", hg_scanner_err_name(status_));
notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_GET_IMAGE_OUTTIME, SANE_EVENT_ERROR, ret); // 取图通信超时
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, " > 600DPI:%s\n", hg_scanner_err_name(status_));
break;
}
else if (img_conf_.resolution_dst != 600.0 && ++to_cnt > 20 && !is_auto_paper_scan)
else if (img_conf_.resolution_dst < 600.0 && ++to_cnt > 20 && !is_auto_paper_scan)
{
status_ = ret;
notify_ui_working_status("\351\200\232\344\277\241\350\266\205\346\227\266", SANE_EVENT_ERROR, ret); // 通信超时
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "\345\205\266\344\273\226dpi '%s'\n", hg_scanner_err_name(status_));
notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_GET_IMAGE_OUTTIME, SANE_EVENT_ERROR, ret); // 取图通信超时
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "< 600DPI:%s\n", hg_scanner_err_name(status_));
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::this_thread::sleep_for(std::chrono::milliseconds(400));
if ((get_status() & 0x03) == 0)
{
status_ = SCANNER_ERR_OK;
@ -1142,8 +1143,7 @@ void hg_scanner_239::thread_get_dves_image(void)
ret = status_;
else
status_ = ret = SCANNER_ERR_USER_CANCELED;
//VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "用户取消操作 '%s'\n", hg_scanner_err_name(status_));
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "\347\224\250\346\210\267\345\217\226\346\266\210\346\223\215\344\275\234 '%s'\n", hg_scanner_err_name(status_));
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "%s:%s\n", STATU_DESC_SCANNER_ERR_DEVICE_GET_USER_CANCEL_SCAN, hg_scanner_err_name(status_));
auoto_paper_indx = 0;
break;
}
@ -1167,7 +1167,9 @@ void hg_scanner_239::thread_get_dves_image(void)
LOG_INFO(LOG_LEVEL_DEBUG_INFO, "Really stopped ^_^\n");
//string str = "当前批次扫描完成(第"+to_string(++auoto_paper_indx)+"批)";
string str = "\345\275\223\345\211\215\346\211\271\346\254\241\346\211\253\346\217\217\345\256\214\346\210\220(\347\254\254" + to_string(++auoto_paper_indx) + "\346\211\271)";
//string str = "\345\275\223\345\211\215\346\211\271\346\254\241\346\211\253\346\217\217\345\256\214\346\210\220(\347\254\254" + to_string(++auoto_paper_indx) + "\346\211\271)";
string str = STATU_DESC_SCANNER_ERR_DEVICE_ROUND_SACN_OVER;
str += ":" + to_string(++auoto_paper_indx);
if (is_auto_paper_scan)
notify_ui_working_status(str.c_str(), SANE_EVENT_STATUS, status_);
else

View File

@ -288,7 +288,7 @@ int hg_scanner_400::stop(void)
status_ = SCANNER_ERR_DEVICE_STOPPED;
VLOG_MINI_1(LOG_LEVEL_WARNING, "stop device:(%s)\n", hg_scanner_err_name(status_));
}
notify_ui_working_status("取消扫描", SANE_EVENT_STATUS, status_);
//notify_ui_working_status("取消扫描", SANE_EVENT_STATUS, status_);
//final_imgs_.clear();
return status_;