Skip to content

fix(thumbnail): pass file URL when opening snapshot via DBus - #530

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:fix-381089-thumbnail-open
Oct 27, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:fix-381089-thumbnail-open

Conversation

@add-uos

@add-uos add-uos commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

问题 / Issue

PMS: BUG-381089

相机右下角预览缩略图点击后,打开图片时看图应用被拉起但不显示该照片;打开视频正常。

根因

相机在 v23+ 通过 DBus 调用 com.deepin.imageViewer.openImageFile 时传递的是裸路径(如 /home/xx/Pictures/Camera/UOS_xxx.jpg):

  1. 看图适配器对裸路径不做 file:// 转换(QUrl(裸路径).isLocalFile() == false),原样透传;
  2. QML 侧 setSourcePath 拿裸路径去和 FileControl.getDirImagePath 返回的 URL 列表(file:///...)做匹配,setImageFiles 中 indexOf 失败直接 return,导致看图窗口空白;
  3. openImageFile 返回 false 属于正常 DBus 回复(非 ErrorMessage),相机端此前只判断 ErrorMessage,不会触发回退,形成“假成功”。

影院的适配器内部自行把裸路径转成 file:// URL,所以视频一直正常。

修复

  • 图片/视频分支统一改为传 QUrl::fromLocalFile(filePath).toString()(file:// URL),影院 \w+:// 分支本就兼容;
  • 相机端解析 openImageFile 的 bool 返回值,返回 false 时回退到命令行启动看图 / 文管打开方式,消除假成功。

验证

  • 拍照后点击右下角缩略图,看图正常定位显示该照片;
  • 录像后点击缩略图,影院打开正常;
  • DBus 打开失败时回退命令行路径可用。

Summary by Sourcery

Fix snapshot opening by using file URLs for DBus launches and honoring unsuccessful responses with a fallback opener.

Bug Fixes:

  • Ensure snapshot files open correctly in image viewers by passing local file URLs over DBus.
  • Fall back to command-line opening when the image viewer DBus request returns an unsuccessful result.

Enhancements:

  • Use consistent file URL handling when opening both images and videos through DBus.

Pass file:// URL to imageViewer/movie DBus interface instead of a
bare path, because image viewer matches the file against a URL
list. Fall back to command-line launch when imageViewer returns
false.

通过DBus打开缩略图文件时传file://形式的URL而非裸路径,
看图内部按URL列表匹配文件;看图返回false时回退命令行启动。

Log: 修复相机缩略图打开图片时看图不显示图片的问题
PMS: BUG-381089
Influence: 相机右下角缩略图打开图片可正常显示,视频打开不受影响
@sourcery-ai

sourcery-ai Bot commented Oct 27, 2026

Copy link
Copy Markdown

Sorry @add-uos, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 17 hours and 4 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 27, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates thumbnail media opening to pass file:// URLs required for image-viewer path matching, and uses the DBus boolean result to fall back to command-line opening when the request is unsuccessful.

Sequence diagram for thumbnail media opening with DBus fallback

sequenceDiagram
    participant User
    participant ImageItem
    participant ImageViewer as deepin-image-viewer
    participant Movie as deepin-movie
    participant Fallback as CommandLineFallback

    User->>ImageItem: openFile()
    alt Image
        ImageItem->>ImageItem: QUrl::fromLocalFile(filePath).toString()
        ImageItem->>ImageViewer: openImageFile(fileUrl)
        ImageViewer-->>ImageItem: bool
    else Video
        ImageItem->>ImageItem: QUrl::fromLocalFile(filePath).toString()
        ImageItem->>Movie: openFile(fileUrl)
        Movie-->>ImageItem: DBus reply
    end
    alt DBus request succeeds
        ImageItem-->>User: Media opens in application
    else DBus error or false result
        ImageItem->>Fallback: openWithBackup()
        Fallback-->>User: Media opens via fallback
    end
Loading

File-Level Changes

Change Details Files
Normalize media paths to file URLs before opening them through DBus.
  • Convert image paths with QUrl::fromLocalFile(...).toString() for image viewer requests.
  • Apply the same URL conversion to movie player requests.
src/src/imageitem.cpp
Treat a false DBus return value as an open failure and invoke the existing fallback path.
  • Parse the DBus reply boolean instead of considering every non-error reply successful.
  • Retain successful logging and route false/error replies to command-line fallback handling.
src/src/imageitem.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 95 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交修复了通过 DBus 打开快照时传 file:// URL 的问题,图片分支同时改进了返回值检查逻辑,代码质量良好。但视频分支仅修改了 URL 传递而未同步改进返回值检查,存在一致性缺陷。无安全漏洞。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['视频分支应与图片分支保持一致,同样解析 DBus 返回的布尔值来判断是否真正成功,确保失败时能触发 openWithBackup() 回退']


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['若视频分支也同步改进返回值检查,则注释与实现将完全一致;或在注释中注明仅 URL 传递保持一致']


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例

// 视频分支应同步图片分支的返回值检查逻辑:
// src/src/imageitem.cpp, ImageItem::openFile() 视频分支
connect(watcher, &QDBusPendingCallWatcher::finished, this, [watcher, openWithBackup]() {
    const QDBusMessage retMessage = watcher->reply();
    bool ok = false;
    if (retMessage.type() != QDBusMessage::ErrorMessage) {
        ok = retMessage.arguments().value(0).toBool();
    }
    if (ok) {
        qDebug() << "Successfully opened video with deepin-movie via DBus";
    } else {
        qWarning() << "Failed to open video with deepin-movie via DBus:" << retMessage.errorMessage();
        if (openWithBackup) {
            openWithBackup();
        }
    }
    watcher->deleteLater();
});

本报告由 AI 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

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

@add-uos

add-uos commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot
deepin-bot Bot merged commit 63109cf into linuxdeepin:master Oct 27, 2026
17 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