fix(multi-select): disable save voice button when no voice in selecte…#352
Merged
deepin-bot[bot] merged 1 commit intoJun 1, 2026
Conversation
…d notes Call checkNoteVoice/checkNoteText in onSelectSizeChanged handler when entering multi-select mode, matching existing context menu pattern. 多选笔记时在onSelectSizeChanged中调用checkNoteVoice/checkNoteText, 与右键菜单逻辑保持一致,确保无语音笔记被选中时保存语音按钮置灰。 Log: 多选无语音笔记时保存语音按钮置灰 PMS: BUG-339519 Influence: 多选笔记时正确判断是否有语音,无语音则保存语音按钮置灰;同时修复checkNoteVoice空指针问题。
|
Note
详情{
"src/common/VNoteMainManager.cpp": [
{
"line": " url = \"https://www.deepin.org/zh/agreement/privacy/\";",
"line_number": 1187,
"rule": "S35",
"reason": "Url link | 20e2eab189"
},
{
"line": " url = \"https://www.uniontech.com/agreement/privacy-cn\";",
"line_number": 1189,
"rule": "S35",
"reason": "Url link | 4850a00dd7"
},
{
"line": " url = \"https://www.deepin.org/en/agreement/privacy/\";",
"line_number": 1193,
"rule": "S35",
"reason": "Url link | 38d42f63bf"
},
{
"line": " url = \"https://www.uniontech.com/agreement/privacy-en\";",
"line_number": 1195,
"rule": "S35",
"reason": "Url link | f82409d3b5"
}
]
} |
deepin pr auto review你好!我是CodeGeeX。我已仔细审查了你提供的Git Diff代码。这次修改主要涉及空指针安全修复和多选状态下的批量检查逻辑。 总体来说,这次修改修复了一个严重的崩溃隐患,并增加了多选时的业务逻辑。以下是我对各个维度的详细审查意见和改进建议: 1. 语法与逻辑C++ 部分 (
QML 部分 (
2. 代码质量QML 部分 (
3. 代码性能QML 部分 (
4. 代码安全C++ 部分 (
QML 部分 (
综合改进后的代码建议基于以上分析,我为你提供优化后的代码实现: C++ 部分 (进一步加固)void VNoteMainManager::checkNoteVoice(const QVariantList &index)
{
bool hasVoice = false;
foreach (auto id, index) {
bool ok = false;
int noteIndex = id.toInt(&ok); // 增加类型转换安全校验
if (!ok) continue; // 如果转换失败,跳过该项
VNoteItem *item = getNoteById(noteIndex);
if (item && item->haveVoice()) { // 保留了你的空指针修复
hasVoice = true;
break;
}
}
// ... 后续逻辑
}QML 部分 (提升性能、安全性与可读性)// 提取为独立函数,提升代码可读性与复用性
function checkSelectedNotes() {
if (selectedNoteItem.length <= 1) {
// 可选:处理单选或无选择时的逻辑重置
return;
}
// 提前分配数组大小,比 push 略微提升性能
var list = new Array(selectedNoteItem.length);
for (var i = 0; i < selectedNoteItem.length; i++) {
var modelItem = itemModel.get(selectedNoteItem[i]);
// 防御性编程:防止 model 发生变动导致越界或访问 undefined
if (modelItem && modelItem.noteId !== undefined) {
list[i] = modelItem.noteId;
} else {
list[i] = -1; // 填充无效ID,C++端应能处理无效ID
}
}
// 性能优化建议:如果C++端能合并这两个接口为 checkNoteVoiceAndText(list) 会更好
VNoteMainManager.checkNoteVoice(list);
VNoteMainManager.checkNoteText(list);
}
onSelectSizeChanged: {
mulChoices(selectSize);
checkSelectedNotes(); // 调用封装好的逻辑
}希望这些审查意见和代码改进能对你有所帮助!如果有任何疑问,欢迎随时提问。 |
lzwind
approved these changes
Jun 1, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx 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 |
Contributor
Author
|
/merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…d notes
Call checkNoteVoice/checkNoteText in onSelectSizeChanged handler when entering multi-select mode, matching existing context menu pattern.
多选笔记时在onSelectSizeChanged中调用checkNoteVoice/checkNoteText, 与右键菜单逻辑保持一致,确保无语音笔记被选中时保存语音按钮置灰。
Log: 多选无语音笔记时保存语音按钮置灰
PMS: BUG-339519
Influence: 多选笔记时正确判断是否有语音,无语音则保存语音按钮置灰;同时修复checkNoteVoice空指针问题。