From d3462ee56bf689b40738cdf5e9a3b378e9996d4e Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Fri, 23 May 2025 13:50:38 +0800 Subject: internal: fix memory leaks --- services/Wallpapers.qml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'services/Wallpapers.qml') diff --git a/services/Wallpapers.qml b/services/Wallpapers.qml index 1d2a097..4bfa72f 100644 --- a/services/Wallpapers.qml +++ b/services/Wallpapers.qml @@ -12,7 +12,7 @@ Singleton { readonly property string currentNamePath: `${StandardPaths.standardLocations(StandardPaths.GenericStateLocation)[0]}/caelestia/wallpaper/last.txt`.slice(7) readonly property string path: `${StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]}/Wallpapers`.slice(7) - property list list + readonly property list list: wallpapers.instances property bool showPreview: false readonly property string current: showPreview ? previewPath : actualCurrent property string previewPath @@ -84,23 +84,19 @@ Singleton { command: ["fd", ".", root.path, "-t", "f", "-e", "jpg", "-e", "jpeg", "-e", "png", "-e", "svg"] stdout: SplitParser { splitMarker: "" - onRead: data => { - const list = data.trim().split("\n"); - root.list = list.map(p => wallpaperComp.createObject(root, { - path: p - })); - } + onRead: data => wallpapers.model = data.trim().split("\n") } } - component Wallpaper: QtObject { - required property string path - readonly property string name: path.slice(path.lastIndexOf("/") + 1, path.lastIndexOf(".")) - } - - Component { - id: wallpaperComp + Variants { + id: wallpapers Wallpaper {} } + + component Wallpaper: QtObject { + required property string modelData + readonly property string path: modelData + readonly property string name: path.slice(path.lastIndexOf("/") + 1, path.lastIndexOf(".")) + } } -- cgit v1.2.3-freya