修复初始化条件默认值BUG
This commit is contained in:
parent
f08f2ac612
commit
cc01febafb
|
@ -1198,24 +1198,24 @@ void device_option::insert_option(gb_json* opt, sane_opt_provider* from, const c
|
|||
from->add_ref();
|
||||
}
|
||||
|
||||
if (added)
|
||||
{
|
||||
// restore to default value ...
|
||||
int size = 0;
|
||||
bool can_auto = false;
|
||||
std::string val(get_option_value(opt->key().c_str(), SANE_ACTION_GET_DEFAULT_VALUE, &size));
|
||||
|
||||
if (!opt->get_value("auto", can_auto) || can_auto)
|
||||
{
|
||||
std::string type("");
|
||||
opt->get_value("type", type);
|
||||
val.resize(size);
|
||||
type = sane_opt_provider::sane_value_2_text(type.c_str(), &val[0]);
|
||||
utils::to_log(LOG_LEVEL_ALL, "Set option '%s' to default value: '%s'\n", opt->key().c_str(), type.c_str());
|
||||
from->set_value(opt->key().c_str(), &val[0]);
|
||||
sane_opt_provider::set_opt_value(opt, &val[0]);
|
||||
}
|
||||
}
|
||||
//if (added) // error occurs when condition default value, move to after to_now ...
|
||||
//{
|
||||
// // restore to default value ...
|
||||
// int size = 0;
|
||||
// bool can_auto = false;
|
||||
// std::string val(get_option_value(opt->key().c_str(), SANE_ACTION_GET_DEFAULT_VALUE, &size));
|
||||
//
|
||||
// if (!opt->get_value("auto", can_auto) || can_auto)
|
||||
// {
|
||||
// std::string type("");
|
||||
// opt->get_value("type", type);
|
||||
// val.resize(size);
|
||||
// type = sane_opt_provider::sane_value_2_text(type.c_str(), &val[0]);
|
||||
// utils::to_log(LOG_LEVEL_ALL, "Set option '%s' to default value: '%s'\n", opt->key().c_str(), type.c_str());
|
||||
// from->set_value(opt->key().c_str(), &val[0]);
|
||||
// sane_opt_provider::set_opt_value(opt, &val[0]);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
bool device_option::arrange_raw_json(sane_opt_provider* sop)
|
||||
{
|
||||
|
@ -1703,7 +1703,9 @@ bool device_option::add(sane_opt_provider* sop)
|
|||
if (arrange_raw_json(sop))
|
||||
{
|
||||
ret = to_now(true, nullptr);
|
||||
if (!ret)
|
||||
if (ret)
|
||||
restore(nullptr);
|
||||
else
|
||||
clear();
|
||||
}
|
||||
else
|
||||
|
@ -1909,7 +1911,7 @@ int device_option::restore(sane_opt_provider* holder)
|
|||
child = cur->first_child();
|
||||
while (child)
|
||||
{
|
||||
if (src_.count(child->key()) && src_[child->key()] == holder
|
||||
if ((!holder || src_.count(child->key()) && src_[child->key()] == holder)
|
||||
&& is_auto_restore_default(child->key().c_str()))
|
||||
{
|
||||
std::string val(device_option::option_value(child, true));
|
||||
|
|
Loading…
Reference in New Issue