summaryrefslogtreecommitdiff
path: root/services/Hyprland.qml
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-05-23 13:50:38 +0800
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-05-23 13:50:38 +0800
commitd3462ee56bf689b40738cdf5e9a3b378e9996d4e (patch)
tree0eb6b5838193383e787d6d0a889c4460d89d1827 /services/Hyprland.qml
parentdashboard: fix bongo cat playing when no media (diff)
downloadcaelestia-shell-d3462ee56bf689b40738cdf5e9a3b378e9996d4e.tar.gz
caelestia-shell-d3462ee56bf689b40738cdf5e9a3b378e9996d4e.tar.bz2
caelestia-shell-d3462ee56bf689b40738cdf5e9a3b378e9996d4e.zip
internal: fix memory leaks
Diffstat (limited to 'services/Hyprland.qml')
-rw-r--r--services/Hyprland.qml24
1 files changed, 15 insertions, 9 deletions
diff --git a/services/Hyprland.qml b/services/Hyprland.qml
index 515441e..7a2538e 100644
--- a/services/Hyprland.qml
+++ b/services/Hyprland.qml
@@ -60,12 +60,9 @@ Singleton {
const clients = JSON.parse(data);
const rClients = root.clients;
- const len = rClients.length;
- for (let i = 0; i < len; i++) {
- const client = rClients[i];
- if (!clients.find(c => c.address === client?.address))
- rClients.splice(i, 1);
- }
+ const destroyed = rClients.filter(rc => !clients.find(c => c.address === rc.address));
+ for (const client of destroyed)
+ rClients.splice(rClients.indexOf(client), 1).forEach(c => c.destroy());
for (const client of clients) {
const match = rClients.find(c => c.address === client.address);
@@ -88,9 +85,18 @@ Singleton {
splitMarker: ""
onRead: data => {
const client = JSON.parse(data);
- root.activeClient = client.address ? clientComp.createObject(root, {
- lastIpcObject: client
- }) : null;
+ const rClient = root.activeClient;
+ if (client.address) {
+ if (rClient)
+ rClient.lastIpcObject = client;
+ else
+ root.activeClient = clientComp.createObject(root, {
+ lastIpcObject: client
+ });
+ } else {
+ rClient.destroy();
+ root.activeClient = null;
+ }
}
}
}