fix: handle DConfig list values in search utility#350
Conversation
1. Added type checking for QVariant list values in tryLoadStringListFromDConfigInternal 2. Now properly handles both JSON array format (list type) and semicolon-delimited strings 3. The issue occurred when DConfig stored values as JSON arrays - toString() would return empty 4. Now uses toStringList() for list-type values to correctly parse the configuration Influence: 1. Test search functionality with DConfig settings in both JSON array format 2. Verify semicolon-delimited string parsing remains unchanged 3. Check configuration loading from different DConfig value formats fix: 修复搜索工具中DConfig列表值的处理 1. 在tryLoadStringListFromDConfigInternal中添加了对QVariant列表值的类型 检查 2. 现在能正确处理JSON数组格式(列表类型)和分号分隔的字符串 3. 当DConfig以JSON数组格式存储值时会出现问题 - toString()会返回空值 4. 现在对列表类型值使用toStringList()以正确解析配置 Influence: 1. 测试使用JSON数组格式的DConfig设置的搜索功能 2. 验证分号分隔字符串的解析保持不变 3. 检查从不同DConfig值格式加载配置的情况
There was a problem hiding this comment.
Sorry @Johnson-zs, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Johnson-zs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // src/dfm-search/dfm-search-lib/utils/searchutility.cpp
static std::optional<QStringList> tryLoadStringListFromDConfigInternal(
...
QVariant value = dconfigPtr->value(keyName);
// No need to delete dconfigPtr, dconfigParent will manage it when it goes out of scope.
auto result = SearchUtility::parseVariantToStringList(value);
if (!result.has_value()) {
if (!value.isValid()) {
qDebug() << "DConfig: Key '" << keyName << "' not found in appId:" << appId << "schemaId:" << schemaId;
} else {
qWarning() << "DConfig: Value for key '" << keyName << "' in appId:" << appId << "schemaId:" << schemaId
<< "cannot be converted to QStringList. Actual type:" << value.typeName();
}
}
return result;
} |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
tryLoadStringListFromDConfigInternal
semicolon-delimited strings
toString() would return empty
configuration
Influence:
format
fix: 修复搜索工具中DConfig列表值的处理
检查
Influence: