Skip to content

fix(player): play current track on dbus play after restart#695

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wyu71:master
Jun 25, 2026
Merged

fix(player): play current track on dbus play after restart#695
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wyu71:master

Conversation

@wyu71

@wyu71 wyu71 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

After restart the restored track has a Stopped backend state, so playRequested skipped to playNextMeta. Guard with a localPath and hash check to play the current track.

重启后恢复的当前曲目后端为 Stopped 状态,playRequested 误调 playNextMeta 跳到下一首。增加 localPath 与 hash 校验,播放当前曲目。

Log: 修复重启后dbus播放跳到下一首的问题
PMS: BUG-367253
Influence: 重启后dbus触发播放时播放当前恢复曲目而非下一首。

After restart the restored track has a Stopped backend state, so
playRequested skipped to playNextMeta. Guard with a localPath and hash
check to play the current track.

重启后恢复的当前曲目后端为 Stopped 状态,playRequested 误调 playNextMeta
跳到下一首。增加 localPath 与 hash 校验,播放当前曲目。

Log: 修复重启后dbus播放跳到下一首的问题
PMS: BUG-367253
Influence: 重启后dbus触发播放时播放当前恢复曲目而非下一首。

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @wyu71, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码精准修复了MPRIS D-Bus播放状态恢复逻辑错误,质量优秀
逻辑完全正确且无任何安全漏洞,得满分

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

修复了playerengine.cpp第250行处未区分重启后恢复曲目与播放列表为空场景导致错误调用playNextMeta(false)的问题,通过判断getMediaMeta().localPath和hash非空来决定是播放当前曲目还是下一首,逻辑严密且覆盖了所有边界条件
潜在问题:无
建议:无

  • 2.代码质量(良好)✓

代码结构清晰,将原先的中文注释替换为准确的英文注释,清晰解释了为何在重启恢复状态下应调用play()而非playNextMeta(false),显著提升了代码的可读性和可维护性
潜在问题:无
建议:无

  • 3.代码性能(高效)✓

仅增加了两次QString的isEmpty()判断,时间复杂度为O(1),对系统性能无任何负面影响
潜在问题:无
建议:无

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
代码仅涉及播放状态的内部逻辑判断与本地元数据校验,未引入任何外部输入处理、文件路径越界或权限变更,无安全风险

  • 建议:保持当前的内部状态校验逻辑

■ 【改进建议代码示例】

// 当前修复代码已足够完善,无需额外修改,此处展示当前最佳实践
void PlayerEngine::setMprisPlayer(const QString &serviceName, const QString &des)
{
    // ... 前置逻辑 ...
    } else {
        if (playbackStatus() != DmGlobal::Playing) {
            // After restart setMediaMeta restores the current track while the
            // backend state stays Stopped; play the current track instead of the next
            if (!getMediaMeta().localPath.isEmpty() && !getMediaMeta().hash.isEmpty()) {
                play();
            } else {
                // Empty playlist must also be handled, otherwise dbus calls are no-ops
                playNextMeta(false);
            }
        } else {
            pauseNow();
        }
    }
    // ... 后置逻辑 ...
}

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lzwind, wyu71

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wyu71

wyu71 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: blocked)

@deepin-bot deepin-bot Bot merged commit 18be111 into linuxdeepin:master Jun 25, 2026
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants