fix(multi-image): fix blank page when switching multi-page TIFF frames#292
Merged
Conversation
Cache loaded image data unconditionally in loadFinished() to prevent data loss from duplicate async load requests, and defer delayInfo cleanup until terminal status (Ready/Error) to ensure frame count update completes. 修复多页图切换第二页显示空白的问题,loadFinished() 无条件缓存 加载结果避免竞态丢数据,delayInfo 等待终态再清理确保帧数更新。 Log: 修复多页TIFF切换空白 PMS: BUG-359509 Influence: 修复后多页图(如多页TIFF)可正常逐页切换,不再出现空白或显示错误图片。
deepin pr auto review你好!我是CodeGeeX。我已仔细审查了你提供的Git Diff。本次修改主要涉及两个方面:一是修改了图片缓存插入的逻辑,二是处理了异步加载状态机中的瞬态问题。 以下是我对本次代码变更的详细审查意见,涵盖语法逻辑、代码质量、代码性能和代码安全四个维度: 1. 语法与逻辑
2. 代码质量
3. 代码性能
4. 代码安全
总结与改进建议代码本次修改的核心逻辑(处理异步状态机的瞬态问题)是正确的,但移除 imageinfo.cpp 改进建议: // 建议保留对 waitSet 的检查,或者如果确信需要无条件缓存,请完善注释说明原因。
// 如果坚持无条件缓存,建议增加防重复插入的判断,避免覆盖有效数据
if (data) {
// [修改说明] 移除 waitSet.contains(key) 检查,因为异步状态回调依赖
// loadFinished 必须无条件缓存数据,以保证后续 Ready 状态触发时数据可用。
// 若无此逻辑,多页图的异步更新可能会因缓存未命中而失败。
if (!cache.contains(key)) { // 避免可能的重复插入/覆盖
cache.insert(key, data);
}
qCDebug(logImageViewer) << "Image loaded successfully:" << path << "frame:" << frameIndex
<< "type:" << data->type << "size:" << data->size;
}pathviewproxymodel.cpp 改进建议: // ... 前置代码 ...
ImageInfo *delayInfo = new ImageInfo(url, this);
connect(delayInfo, &ImageInfo::statusChanged, this, [this, delayInfo, sourceIndex]() {
qCDebug(logImageViewer) << "AsyncUpdateLoadInfo: ImageInfo status changed for:" << delayInfo->source().toString();
// Loading is a transient state; wait for a terminal state (Ready/Error).
// Requires loadFinished() to cache data unconditionally so that
// the subsequent Ready status change is guaranteed to fire.
if (ImageInfo::Loading == delayInfo->status()) {
return;
}
// 仅更新加载成功的多页图数据,其它类型的数据无需关注,默认的 frameIndex 都是 0
if (ImageInfo::Ready == delayInfo->status() && Types::MultiImage == delayInfo->type()) {
qCDebug(logImageViewer) << "Async update completed for multi-image:" << delayInfo->source().toString();
// TODO: 考虑如果 status 是 Error,是否需要清理 delayInfo 或发送加载失败信号?
} else if (ImageInfo::Error == delayInfo->status()) {
qCDebug(logImageViewer) << "Async update failed for:" << delayInfo->source().toString();
// 建议处理错误状态,防止异步任务静默失败
}
});希望这些审查意见对你有所帮助!如果有任何需要进一步探讨的细节,欢迎随时提问。 |
lzwind
approved these changes
May 12, 2026
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
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.
Cache loaded image data unconditionally in loadFinished() to prevent data loss from duplicate async load requests, and defer delayInfo cleanup until terminal status (Ready/Error) to ensure frame count update completes.
修复多页图切换第二页显示空白的问题,loadFinished() 无条件缓存
加载结果避免竞态丢数据,delayInfo 等待终态再清理确保帧数更新。
Log: 修复多页TIFF切换空白
PMS: BUG-359509
Influence: 修复后多页图(如多页TIFF)可正常逐页切换,不再出现空白或显示错误图片。