internal: fix memory leaks
This commit is contained in:
parent
3aa7d9d5de
commit
d3462ee56b
7 changed files with 58 additions and 59 deletions
|
|
@ -36,7 +36,7 @@ Item {
|
|||
}
|
||||
}
|
||||
if (pills.length > count)
|
||||
pills.splice(count, pills.length - count);
|
||||
pills.splice(count, pills.length - count).forEach(p => p.destroy());
|
||||
}
|
||||
|
||||
Repeater {
|
||||
|
|
|
|||
|
|
@ -35,12 +35,7 @@ Variants {
|
|||
height: scope.modelData.height - BorderConfig.thickness * 2
|
||||
intersection: Intersection.Xor
|
||||
|
||||
regions: panels.children.map(c => regionComp.createObject(this, {
|
||||
x: c.x,
|
||||
y: c.y,
|
||||
width: c.width,
|
||||
height: c.height
|
||||
}))
|
||||
regions: regions.instances
|
||||
}
|
||||
|
||||
anchors.top: true
|
||||
|
|
@ -48,10 +43,18 @@ Variants {
|
|||
anchors.left: true
|
||||
anchors.right: true
|
||||
|
||||
Component {
|
||||
id: regionComp
|
||||
Variants {
|
||||
id: regions
|
||||
|
||||
model: panels.children
|
||||
|
||||
Region {
|
||||
required property Item modelData
|
||||
|
||||
x: modelData.x
|
||||
y: modelData.y
|
||||
width: modelData.width
|
||||
height: modelData.height
|
||||
intersection: Intersection.Subtract
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,12 +43,9 @@ Singleton {
|
|||
const devices = JSON.parse(data).filter(d => d.Name);
|
||||
const rDevices = root.devices;
|
||||
|
||||
const len = rDevices.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
const device = rDevices[i];
|
||||
if (!devices.find(d => d.Address === device?.address))
|
||||
rDevices.splice(i, 1);
|
||||
}
|
||||
const destroyed = rDevices.filter(rd => !devices.find(d => d.Address === rd.address));
|
||||
for (const device of destroyed)
|
||||
rDevices.splice(rDevices.indexOf(device), 1).forEach(d => d.destroy());
|
||||
|
||||
for (const device of devices) {
|
||||
const match = rDevices.find(d => d.address === device.Address);
|
||||
|
|
|
|||
|
|
@ -10,24 +10,22 @@ Singleton {
|
|||
id: root
|
||||
|
||||
property var ddcMonitors: []
|
||||
readonly property list<Monitor> monitors: Quickshell.screens.map(screen => monitorComp.createObject(root, {
|
||||
screen
|
||||
}))
|
||||
readonly property list<Monitor> monitors: variants.instances
|
||||
|
||||
function getMonitorForScreen(screen: ShellScreen): var {
|
||||
return monitors.find(m => m.screen === screen);
|
||||
return monitors.find(m => m.modelData === screen);
|
||||
}
|
||||
|
||||
function increaseBrightness(): void {
|
||||
const focusedName = Hyprland.focusedMonitor.name;
|
||||
const monitor = monitors.find(m => focusedName === m.screen.name);
|
||||
const monitor = monitors.find(m => focusedName === m.modelData.name);
|
||||
if (monitor)
|
||||
monitor.setBrightness(monitor.brightness + 0.1);
|
||||
}
|
||||
|
||||
function decreaseBrightness(): void {
|
||||
const focusedName = Hyprland.focusedMonitor.name;
|
||||
const monitor = monitors.find(m => focusedName === m.screen.name);
|
||||
const monitor = monitors.find(m => focusedName === m.modelData.name);
|
||||
if (monitor)
|
||||
monitor.setBrightness(monitor.brightness - 0.1);
|
||||
}
|
||||
|
|
@ -39,6 +37,14 @@ Singleton {
|
|||
ddcProc.running = true;
|
||||
}
|
||||
|
||||
Variants {
|
||||
id: variants
|
||||
|
||||
model: Quickshell.screens
|
||||
|
||||
Monitor {}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: ddcProc
|
||||
|
||||
|
|
@ -75,9 +81,9 @@ Singleton {
|
|||
component Monitor: QtObject {
|
||||
id: monitor
|
||||
|
||||
required property ShellScreen screen
|
||||
readonly property bool isDdc: root.ddcMonitors.some(m => m.model === screen.model)
|
||||
readonly property string busNum: root.ddcMonitors.find(m => m.model === screen.model)?.busNum ?? ""
|
||||
required property ShellScreen modelData
|
||||
readonly property bool isDdc: root.ddcMonitors.some(m => m.model === modelData.model)
|
||||
readonly property string busNum: root.ddcMonitors.find(m => m.model === modelData.model)?.busNum ?? ""
|
||||
property real brightness
|
||||
|
||||
readonly property Process initProc: Process {
|
||||
|
|
@ -109,10 +115,4 @@ Singleton {
|
|||
initProc.running = true;
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: monitorComp
|
||||
|
||||
Monitor {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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, {
|
||||
const rClient = root.activeClient;
|
||||
if (client.address) {
|
||||
if (rClient)
|
||||
rClient.lastIpcObject = client;
|
||||
else
|
||||
root.activeClient = clientComp.createObject(root, {
|
||||
lastIpcObject: client
|
||||
}) : null;
|
||||
});
|
||||
} else {
|
||||
rClient.destroy();
|
||||
root.activeClient = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,12 +29,9 @@ Singleton {
|
|||
const networks = JSON.parse(data).map(n => [n[0] === "yes", parseInt(n[1]), parseInt(n[2]), n[3]]);
|
||||
const rNetworks = root.networks;
|
||||
|
||||
const len = rNetworks.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
const network = rNetworks[i];
|
||||
if (!networks.find(n => n[2] === network?.frequency && n[3] === network?.ssid))
|
||||
rNetworks.splice(i, 1);
|
||||
}
|
||||
const destroyed = rNetworks.filter(rn => !networks.find(n => n[2] === rn.frequency && n[3] === rn.ssid));
|
||||
for (const network of destroyed)
|
||||
rNetworks.splice(rNetworks.indexOf(network), 1).forEach(n => n.destroy());
|
||||
|
||||
for (const network of networks) {
|
||||
const match = rNetworks.find(n => n.frequency === network[2] && n.ssid === network[3]);
|
||||
|
|
|
|||
|
|
@ -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("."))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue