Skip to content

fix(wallpaper): pass custom wallpaper by fd#273

Open
mhduiy wants to merge 1 commit into
linuxdeepin:masterfrom
mhduiy:customwallpaperfd
Open

fix(wallpaper): pass custom wallpaper by fd#273
mhduiy wants to merge 1 commit into
linuxdeepin:masterfrom
mhduiy:customwallpaperfd

Conversation

@mhduiy

@mhduiy mhduiy commented Jun 30, 2026

Copy link
Copy Markdown
Contributor
  1. Open custom wallpaper files in dde-appearance before calling dde-daemon.
  2. Pass a DBus Unix fd with filename metadata to SaveCustomWallPaper.
  3. Keep solid wallpaper handling explicit with the new isSolid argument.
  4. Require a dde-daemon version that provides the fd-based wallpaper API.

Log: Adapt dde-appearance custom wallpaper saving to the fd-based daemon API.

fix(wallpaper): 通过fd传递自定义壁纸

  1. 在 dde-appearance 调用 dde-daemon 前先打开自定义壁纸文件。
  2. 调用 SaveCustomWallPaper 时传递 DBus Unix fd 和文件名元数据。
  3. 通过新的 isSolid 参数显式保留纯色壁纸处理。
  4. 依赖提供 fd 壁纸接口的 dde-daemon 版本。

Log: 适配 dde-appearance 基于 fd 的自定义壁纸保存接口。
PMS: BUG-368175

@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 @mhduiy, 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

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy

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

1. Open custom wallpaper files in dde-appearance before calling dde-daemon.
2. Pass a DBus Unix fd with filename metadata to SaveCustomWallPaper.
3. Keep solid wallpaper handling explicit with the new isSolid argument.
4. Require a dde-daemon version that provides the fd-based wallpaper API.

Log: Adapt dde-appearance custom wallpaper saving to the fd-based daemon API.

fix(wallpaper): 通过fd传递自定义壁纸

1. 在 dde-appearance 调用 dde-daemon 前先打开自定义壁纸文件。
2. 调用 SaveCustomWallPaper 时传递 DBus Unix fd 和文件名元数据。
3. 通过新的 isSolid 参数显式保留纯色壁纸处理。
4. 依赖提供 fd 壁纸接口的 dde-daemon 版本。

Log: 适配 dde-appearance 基于 fd 的自定义壁纸保存接口。
PMS: BUG-368175
@mhduiy mhduiy force-pushed the customwallpaperfd branch from 5f5ef19 to 916c1d0 Compare July 2, 2026 09:19
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:65分

■ 【总体评价】

代码通过Unix文件描述符传递壁纸数据提升了安全性,但存在严重的异步调用逻辑错误导致功能完全失效
逻辑正确但因核心逻辑错误扣35分

■ 【详细分析】

  • 1.语法逻辑(存在错误)✕
    AppearanceDBusProxy::SaveCustomWallPaper函数中,使用了QDBusConnection::systemBus().asyncCall(daemonMessage)进行异步DBus调用,但函数返回类型为QString。将异步调用的QDBusPendingReply隐式转换为QString时,由于底层IPC调用尚未完成,Qt会触发警告并直接返回默认构造的空字符串,导致保存壁纸的功能完全失效。
    潜在问题:函数永远无法返回正确的壁纸保存路径;调用方会误以为保存失败
    建议:将asyncCall替换为同步的call方法以正确获取返回值,或将函数返回值类型改为QDBusPendingReply<QString>由调用方处理异步逻辑
  • 2.代码质量(良好)✓
    代码增加了文件有效性校验,提升了鲁棒性,通过FD传递文件句柄的设计符合安全规范。使用了局部对象QFile管理文件生命周期,避免了手动内存管理。
    潜在问题:错误处理仅返回空字符串,缺乏日志记录,不利于问题排查;使用了C风格字符串字面量""而非QString()
    建议:在返回空字符串前增加qWarning()日志输出错误原因;将""统一替换为QString()
  • 3.代码性能(无性能问题)✓
    文件读取与元数据校验操作仅针对单张壁纸文件,磁盘I/O开销极小。通过文件描述符传递避免了跨进程的大文件数据拷贝,性能表现良好。
    建议:保持现有实现
  • 4.代码安全(存在0个安全漏洞)✓
    漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
    代码将传参方式从直接传递文件路径更改为通过Unix文件描述符传递,有效避免了路径遍历和符号链接攻击风险。文件打开前进行了可读性和文件类型校验,防止了无效句柄传递给dde-daemon守护进程。
  • 建议:继续保持使用FD传递文件的安全设计模式,避免在DBus接口中暴露绝对路径

■ 【改进建议代码示例】

QString AppearanceDBusProxy::SaveCustomWallPaper(const QString &username, const QString &file, bool isSolid)
{
    QFileInfo wallpaperInfo(file);
    if (!wallpaperInfo.isFile() || !wallpaperInfo.isReadable()) {
        qWarning() << "SaveCustomWallPaper: Invalid or unreadable file:" << file;
        return QString();
    }

    QFile wallpaper(file);
    if (!wallpaper.open(QIODevice::ReadOnly)) {
        qWarning() << "SaveCustomWallPaper: Failed to open file:" << file;
        return QString();
    }

    QDBusUnixFileDescriptor fd(wallpaper.handle());
    if (!fd.isValid()) {
        qWarning() << "SaveCustomWallPaper: Invalid file descriptor for file:" << file;
        return QString();
    }

    QDBusMessage daemonMessage = QDBusMessage::createMethodCall(DaemonService, DaemonPath, DaemonInterface, "SaveCustomWallPaper");
    daemonMessage << username << QVariant::fromValue(fd) << isSolid;
    
    QDBusMessage reply = QDBusConnection::systemBus().call(daemonMessage);
    if (reply.type() == QDBusMessage::ReplyMessage) {
        return reply.arguments().value(0).toString();
    }
    
    qWarning() << "SaveCustomWallPaper: DBus call failed:" << reply.errorMessage();
    return QString();
}

@deepin-ci-robot

Copy link
Copy Markdown

@mhduiy: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
github-pr-review-ci 916c1d0 link true /test github-pr-review-ci

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

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.

2 participants