解决sane配置类型为desp->constraint_type == SANE_CONSTRAINT_NONE时导致的问题

This commit is contained in:
luoliangyi 2024-03-08 14:27:35 +08:00
parent 0ff946eab1
commit b1c6eb6899
2 changed files with 34 additions and 31 deletions

View File

@ -560,18 +560,19 @@ HGLibDeviceParamGroup* HGLibDeviceImpl::GetParamGroupList(HGUInt* count)
devParam.valueType = HGLIB_OPTION_VALUETYPE_ENUM; devParam.valueType = HGLIB_OPTION_VALUETYPE_ENUM;
devParam.stringValue = value; devParam.stringValue = value;
assert(SANE_CONSTRAINT_STRING_LIST == desp->constraint_type); devParam.rangeType = HGLIB_OPTION_VALUERANGETYPE_ENUMLIST;
if (SANE_CONSTRAINT_STRING_LIST == desp->constraint_type)
{
const SANE_String_Const* p = desp->constraint.string_list;
while (NULL != *p)
{
devParam.stringValueList.push_back(*p);
++p;
}
devParam.rangeType = HGLIB_OPTION_VALUERANGETYPE_ENUMLIST; assert(!devParams.empty());
const SANE_String_Const* p = desp->constraint.string_list; devParams[devParams.size() - 1].devParams.push_back(devParam);
while (NULL != *p) }
{
devParam.stringValueList.push_back(*p);
++p;
}
assert(!devParams.empty());
devParams[devParams.size() - 1].devParams.push_back(devParam);
} }
else if (SANE_TYPE_INT == desp->type) else if (SANE_TYPE_INT == desp->type)
{ {
@ -763,15 +764,16 @@ HGLibDeviceParam* HGLibDeviceImpl::GetParam(HGUInt option)
devParam.valueType = HGLIB_OPTION_VALUETYPE_ENUM; devParam.valueType = HGLIB_OPTION_VALUETYPE_ENUM;
devParam.stringValue = value; devParam.stringValue = value;
assert(SANE_CONSTRAINT_STRING_LIST == desp->constraint_type); devParam.rangeType = HGLIB_OPTION_VALUERANGETYPE_ENUMLIST;
if (SANE_CONSTRAINT_STRING_LIST == desp->constraint_type)
devParam.rangeType = HGLIB_OPTION_VALUERANGETYPE_ENUMLIST; {
const SANE_String_Const* p = desp->constraint.string_list; const SANE_String_Const* p = desp->constraint.string_list;
while (NULL != *p) while (NULL != *p)
{ {
devParam.stringValueList.push_back(*p); devParam.stringValueList.push_back(*p);
++p; ++p;
} }
}
} }
else if (SANE_TYPE_INT == desp->type) else if (SANE_TYPE_INT == desp->type)
{ {

View File

@ -3528,18 +3528,19 @@ namespace ver_2
devParam.valueType = 1; devParam.valueType = 1;
devParam.stringValue = value; devParam.stringValue = value;
assert(SANE_CONSTRAINT_STRING_LIST == desp->constraint_type); devParam.rangeType = 1;
if (SANE_CONSTRAINT_STRING_LIST == desp->constraint_type)
{
const SANE_String_Const* p = desp->constraint.string_list;
while (NULL != *p)
{
devParam.stringValueList.push_back(*p);
++p;
}
devParam.rangeType = 1; assert(!devParams.empty());
const SANE_String_Const* p = desp->constraint.string_list; devParams[devParams.size() - 1].devParams.push_back(devParam);
while (NULL != *p) }
{
devParam.stringValueList.push_back(*p);
++p;
}
assert(!devParams.empty());
devParams[devParams.size() - 1].devParams.push_back(devParam);
} }
else if (SANE_TYPE_INT == desp->type) else if (SANE_TYPE_INT == desp->type)
{ {