From 74d3906f4ee4b68865921ba3c96ed33c38749fa5 Mon Sep 17 00:00:00 2001 From: caixiangrong Date: Fri, 6 Feb 2026 10:33:45 +0800 Subject: [PATCH] fix: fix cache image error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed a bug in the cache image function where a nullptr was being passed as the CacheImageResponse parameter, which could cause crashes or incorrect behavior when caching images. Now properly creates a new CacheImageResponse object with the appropriate parameters. The change ensures that when caching images without a specific response object, a valid CacheImageResponse is created with the image ID and default size parameters, preventing potential null pointer issues and ensuring proper image caching functionality. Influence: 1. Test image loading and caching functionality in control center 2. Verify that images are properly cached without crashes 3. Check memory usage to ensure no leaks from new CacheImageResponse objects 4. Test with various image sizes and formats 5. Verify thumbnail generation works correctly fix: 修复缓存图片错误 修复了缓存图片函数中的一个bug,该bug会导致在缓存图片时传递nullptr作为 CacheImageResponse参数,可能引起崩溃或图片缓存不正确的问题。现在正确创建 了带有适当参数的CacheImageResponse对象。 此修改确保在没有特定响应对象时缓存图片,会创建一个包含图片ID和默认尺寸 参数的有效CacheImageResponse,防止潜在的空指针问题并确保图片缓存功能正常 工作。 Influence: 1. 测试控制中心中的图片加载和缓存功能 2. 验证图片缓存功能正常且不会崩溃 3. 检查内存使用情况,确保新的CacheImageResponse对象不会导致内存泄漏 4. 测试各种图片尺寸和格式 5. 验证缩略图生成功能正常工作 Fixes: #340297 --- src/dde-control-center/plugin/dccimageprovider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dde-control-center/plugin/dccimageprovider.cpp b/src/dde-control-center/plugin/dccimageprovider.cpp index a68493df68..d77f596225 100644 --- a/src/dde-control-center/plugin/dccimageprovider.cpp +++ b/src/dde-control-center/plugin/dccimageprovider.cpp @@ -121,7 +121,7 @@ DccImageProvider::~DccImageProvider() QImage *DccImageProvider::cacheImage(const QString &id, const QSize &thumbnailSize) { - return cacheImage(id, thumbnailSize, nullptr, QSize()); + return cacheImage(id, thumbnailSize, new CacheImageResponse(id, QSize(), this), QSize()); } QImage *DccImageProvider::cacheImage(const QString &id, const QSize &thumbnailSize, CacheImageResponse *response, const QSize &requestedSize)