diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-23 13:50:38 +0800 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-23 13:50:38 +0800 |
| commit | d3462ee56bf689b40738cdf5e9a3b378e9996d4e (patch) | |
| tree | 0eb6b5838193383e787d6d0a889c4460d89d1827 /services/Wallpapers.qml | |
| parent | dashboard: fix bongo cat playing when no media (diff) | |
| download | caelestia-shell-d3462ee56bf689b40738cdf5e9a3b378e9996d4e.tar.gz caelestia-shell-d3462ee56bf689b40738cdf5e9a3b378e9996d4e.tar.bz2 caelestia-shell-d3462ee56bf689b40738cdf5e9a3b378e9996d4e.zip | |
internal: fix memory leaks
Diffstat (limited to 'services/Wallpapers.qml')
| -rw-r--r-- | services/Wallpapers.qml | 24 |
1 files changed, 10 insertions, 14 deletions
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<Wallpaper> list + readonly property list<Wallpaper> 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(".")) + } } |