Skip to content

Commit deedff7

Browse files
committed
fix(wallpaper-cache): support ENABLE_DSS_SNIPE and close file handle
- Use conditional compilation for wallpaper cache service verification. - Added DBus interface validity check when ENABLE_DSS_SNIPE is defined. - Close origin image file handle to prevent leaks. - 在验证壁纸缓存服务时增加条件编译支持。 - 当定义了 ENABLE_DSS_SNIPE 时,增加 DBus 接口有效性检查。 - 关闭原始图片文件句柄以防止泄漏。 Log: fix(wallpaper-cache): support ENABLE_DSS_SNIPE and close file handle Change-Id: I5440d4c3ebed502629f415c7ddb1ff0358cf1f31
1 parent 8d6fdf4 commit deedff7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/widgets/fullscreenbackground.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2011 - 2022 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2011 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -743,16 +743,24 @@ QString FullScreenBackground::sizeToString(const QSize &size)
743743

744744
bool FullScreenBackground::getScaledBlurImage(const QString &originPath, QString &scaledPath)
745745
{
746+
#ifndef ENABLE_DSS_SNIPE
746747
// 为了兼容没有安装壁纸服务环境;Qt5.15高版本可以使用activatableServiceNames()遍历然后可判断系统有没有安装服务
747748
const QString wallpaperServicePath = "/lib/systemd/system/dde-wallpaper-cache.service";
748749
if (!QFile::exists(wallpaperServicePath)) {
749750
qWarning() << "dde-wallpaper-cache service not existed";
750751
return false;
751752
}
753+
#endif
752754

753755
// 壁纸服务dde-wallpaper-cache
754756
QDBusInterface wallpaperCacheInterface("org.deepin.dde.WallpaperCache", "/org/deepin/dde/WallpaperCache",
755757
"org.deepin.dde.WallpaperCache", QDBusConnection::systemBus());
758+
#ifdef ENABLE_DSS_SNIPE
759+
if (!wallpaperCacheInterface.isValid()) {
760+
qWarning() << "dde-wallpaper-cache service not existed";
761+
return false;
762+
}
763+
#endif
756764

757765
QFile file(originPath);
758766
if (!file.open(QIODevice::ReadOnly)) {
@@ -775,6 +783,8 @@ bool FullScreenBackground::getScaledBlurImage(const QString &originPath, QString
775783
return false;
776784
}
777785

786+
file.close();
787+
778788
QString path = pathList.value().at(0);
779789
if (!path.isEmpty() && path != originPath) {
780790
scaledPath = path;

0 commit comments

Comments
 (0)