fix(wallpaper): show video previews#3351
Conversation
|
/test github-pr-review-ci |
|
/test "Call CLA check / clacheck / CLAssistant (pull_request_target)" |
|
@mhduiy: The specified target(s) for
Use
DetailsIn response to this:
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. |
|
/test "Call CLA check" |
|
@mhduiy: The specified target(s) for
Use
DetailsIn response to this:
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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: caixr23, mhduiy 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 |
|
/merge |
|
This pr cannot be merged! (status: behind) |
1. Resolve packaged and cached video thumbnails for display previews. 2. Generate shared thumbnail caches with atomic temporary files. 3. Reuse the common thumbnail utility in the personalization provider. 4. Prevent stale asynchronous results from replacing newer wallpapers. Log: Fix missing video wallpaper previews in display settings. fix(wallpaper): 显示视频壁纸预览 1. 为显示预览读取壁纸包缩略图和视频缩略图缓存。 2. 通过临时文件原子生成并复用公共缩略图缓存。 3. 在个性化壁纸提供者中复用公共缩略图工具。 4. 防止过期异步结果覆盖后来设置的壁纸。 Log: 修复显示设置中缺少视频壁纸预览的问题。 PMS: BUG-367369
f48803d to
6e02e8f
Compare
|
/test github-pr-review-ci |
deepin pr auto review★ 总体评分:55分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 修复 DisplayWorker::resolveVideoThumbnail 中的路径遍历漏洞
QString DisplayWorker::resolveVideoThumbnail(const QString &videoPath, Monitor *monitor)
{
QDir liveDir(SysLiveWallpaperDir);
if (liveDir.exists()) {
QFile metaFile(liveDir.absoluteFilePath("metadata.json"));
if (metaFile.open(QIODevice::ReadOnly)) {
QJsonParseError parseErr;
QJsonDocument doc = QJsonDocument::fromJson(metaFile.readAll(), &parseErr);
metaFile.close();
if (parseErr.error != QJsonParseError::NoError || !doc.isArray()) {
qCWarning(DdcDisplayWorker) << "metadata.json parse error:" << parseErr.errorString();
} else {
for (const auto &entry : doc.array()) {
QJsonObject obj = entry.toObject();
QString videoAbsPath = liveDir.absoluteFilePath(obj.value("path").toString());
if (videoAbsPath == videoPath) {
QString thumbnailRel = obj.value("thumbnail").toString();
if (!thumbnailRel.isEmpty()) {
// 修复路径遍历:确保拼接后的路径仍在 liveDir 目录下
QString thumbAbsPath = liveDir.absoluteFilePath(thumbnailRel);
QString cleanedPath = QDir::cleanPath(thumbAbsPath);
QString cleanedLiveDir = QDir::cleanPath(liveDir.absolutePath());
if (cleanedPath.startsWith(cleanedLiveDir + "/") && QFile::exists(cleanedPath)) {
return cleanedPath;
} else {
qCWarning(DdcDisplayWorker) << "Invalid thumbnail path detected:" << thumbnailRel;
}
}
break;
}
}
}
}
}
const QString cachePath = DccWallpaperThumbnail::cachePath(videoPath);
if (QFile::exists(cachePath)) {
return cachePath;
}
if (monitor && m_videoWallpaperMonitors.contains(videoPath)) {
m_videoWallpaperMonitors[videoPath].append(monitor);
return videoPath;
}
if (monitor) {
m_videoWallpaperMonitors[videoPath] = { monitor };
}
QPointer<DisplayWorker> guard(this);
(void)QtConcurrent::run([guard, videoPath]() {
const QString thumbnailPath = DccWallpaperThumbnail::generate(videoPath);
if (guard)
Q_EMIT guard->videoThumbnailReady(videoPath, thumbnailPath);
});
return videoPath;
}
// 修复 videoThumbnailReady 槽函数中的逻辑瑕疵
// 在构造函数中连接的 lambda
connect(this, &DisplayWorker::videoThumbnailReady, this, [this](const QString &videoPath, const QString &thumbnailPath) {
const auto monitors = m_videoWallpaperMonitors.take(videoPath);
if (thumbnailPath.isEmpty()) {
qCWarning(DdcDisplayWorker) << "Failed to generate thumbnail for:" << videoPath;
// 可选:在此处恢复默认壁纸或进行其他错误处理
return;
}
for (const auto &monitor : monitors) {
if (monitor && monitor->wallpaper() == videoPath)
monitor->setWallpaper(thumbnailPath);
}
}); |
|
@mhduiy: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
|
TAG Bot New tag: 6.1.100 |
Summary
Verification
cmake --build build --target display personalization -j6./build/bin/dcc-wallpaper-utils-test --gtest_color=no(2 tests passed)PMS: BUG-367369