初始化IP地址;修复重构属性时的序号错误

This commit is contained in:
gb 2023-11-06 17:18:48 +08:00
parent 9007ae0c28
commit 6ca7d1674d
3 changed files with 21 additions and 10 deletions

View File

@ -2261,6 +2261,14 @@ void hg_scanner::init_settings(const char* json_setting_text)
child->set_value("default", val.c_str()); child->set_value("default", val.c_str());
child->release(); child->release();
} }
jsn->get_value(SANE_STD_OPT_NAME_DEVICE_IP_ADDR, child);
if(child)
{
std::string val(get_ip());
child->set_value("cur", val.c_str());
child->set_value("default", val.c_str());
child->release();
}
text = std::move(jsn->to_string()); text = std::move(jsn->to_string());
} }

View File

@ -801,18 +801,18 @@ SANE_Status hg_sane_middleware::control_option(SANE_Handle h, const void* option
if (action == SANE_ACTION_SET_AUTO) if (action == SANE_ACTION_SET_AUTO)
{ {
if(after.empty()) if(after.empty())
utils::to_log_with_api(hg_scanner_log_is_enable, hg_scanner_log, LOG_LEVEL_DEBUG, "Restore '%s' = %s\n" utils::to_log_with_api(hg_scanner_log_is_enable, hg_scanner_log, LOG_LEVEL_DEBUG, "Restore %d - '%s' = %s\n"
, title.c_str(), hg_scanner_err_description(local_utility::sane_statu_2_scanner_err(err))); , (int)(long)option, title.c_str(), hg_scanner_err_description(local_utility::sane_statu_2_scanner_err(err)));
else else
utils::to_log_with_api(hg_scanner_log_is_enable, hg_scanner_log, LOG_LEVEL_DEBUG, "Restore '%s' to '%s' = %s\n" utils::to_log_with_api(hg_scanner_log_is_enable, hg_scanner_log, LOG_LEVEL_DEBUG, "Restore %d - '%s' to '%s' = %s\n"
, title.c_str(), after.c_str(), hg_scanner_err_description(local_utility::sane_statu_2_scanner_err(err))); , (int)(long)option, title.c_str(), after.c_str(), hg_scanner_err_description(local_utility::sane_statu_2_scanner_err(err)));
} }
else if(before != after) else if(before != after)
utils::to_log_with_api(hg_scanner_log_is_enable, hg_scanner_log, LOG_LEVEL_DEBUG, "set '%s' to '%s'(APPLIED: %s) = %s\n" utils::to_log_with_api(hg_scanner_log_is_enable, hg_scanner_log, LOG_LEVEL_DEBUG, "set %d - '%s' to '%s'(APPLIED: %s) = %s\n"
, title.c_str(), before.c_str(), after.c_str(), hg_scanner_err_description(local_utility::sane_statu_2_scanner_err(err))); , (int)(long)option, title.c_str(), before.c_str(), after.c_str(), hg_scanner_err_description(local_utility::sane_statu_2_scanner_err(err)));
else else
utils::to_log_with_api(hg_scanner_log_is_enable, hg_scanner_log, LOG_LEVEL_DEBUG, "set '%s' to '%s' = %s\n" utils::to_log_with_api(hg_scanner_log_is_enable, hg_scanner_log, LOG_LEVEL_DEBUG, "set %d - '%s' to '%s' = %s\n"
, title.c_str(), before.c_str(), hg_scanner_err_description(local_utility::sane_statu_2_scanner_err(err))); , (int)(long)option, title.c_str(), before.c_str(), hg_scanner_err_description(local_utility::sane_statu_2_scanner_err(err)));
} }
// extension ... // extension ...

View File

@ -397,7 +397,6 @@ bool sane_options::init_from(const char* jsn_text/*all options*/, void(*err_msg)
while (child) while (child)
{ {
str = std::move(child->to_string());
sn++; sn++;
ret = add_or_replace_opt(sn, child, err_msg); ret = add_or_replace_opt(sn, child, err_msg);
child->release(); child->release();
@ -438,7 +437,11 @@ bool sane_options::add_or_replace_opt(int& sn, gb_json* jsn, void(*err_msg)(cons
if (opts_.count(id)) if (opts_.count(id))
{ {
return opts_[id]->from_json_object(jsn, err_msg); bool ret = opts_[id]->from_json_object(jsn, err_msg);
if (!opts_[id]->is_visible())
sn--;
return ret;
} }
sane_opt* opt = new sane_opt(); sane_opt* opt = new sane_opt();