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)
|
if (pills.length > count)
|
||||||
pills.splice(count, pills.length - count);
|
pills.splice(count, pills.length - count).forEach(p => p.destroy());
|
||||||
}
|
}
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,7 @@ Variants {
|
||||||
height: scope.modelData.height - BorderConfig.thickness * 2
|
height: scope.modelData.height - BorderConfig.thickness * 2
|
||||||
intersection: Intersection.Xor
|
intersection: Intersection.Xor
|
||||||
|
|
||||||
regions: panels.children.map(c => regionComp.createObject(this, {
|
regions: regions.instances
|
||||||
x: c.x,
|
|
||||||
y: c.y,
|
|
||||||
width: c.width,
|
|
||||||
height: c.height
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
anchors.top: true
|
anchors.top: true
|
||||||
|
|
@ -48,10 +43,18 @@ Variants {
|
||||||
anchors.left: true
|
anchors.left: true
|
||||||
anchors.right: true
|
anchors.right: true
|
||||||
|
|
||||||
Component {
|
Variants {
|
||||||
id: regionComp
|
id: regions
|
||||||
|
|
||||||
|
model: panels.children
|
||||||
|
|
||||||
Region {
|
Region {
|
||||||
|
required property Item modelData
|
||||||
|
|
||||||
|
x: modelData.x
|
||||||
|
y: modelData.y
|
||||||
|
width: modelData.width
|
||||||
|
height: modelData.height
|
||||||
intersection: Intersection.Subtract
|
intersection: Intersection.Subtract
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,9 @@ Singleton {
|
||||||
const devices = JSON.parse(data).filter(d => d.Name);
|
const devices = JSON.parse(data).filter(d => d.Name);
|
||||||
const rDevices = root.devices;
|
const rDevices = root.devices;
|
||||||
|
|
||||||
const len = rDevices.length;
|
const destroyed = rDevices.filter(rd => !devices.find(d => d.Address === rd.address));
|
||||||
for (let i = 0; i < len; i++) {
|
for (const device of destroyed)
|
||||||
const device = rDevices[i];
|
rDevices.splice(rDevices.indexOf(device), 1).forEach(d => d.destroy());
|
||||||
if (!devices.find(d => d.Address === device?.address))
|
|
||||||
rDevices.splice(i, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const device of devices) {
|
for (const device of devices) {
|
||||||
const match = rDevices.find(d => d.address === device.Address);
|
const match = rDevices.find(d => d.address === device.Address);
|
||||||
|
|
|
||||||
|
|
@ -10,24 +10,22 @@ Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property var ddcMonitors: []
|
property var ddcMonitors: []
|
||||||
readonly property list<Monitor> monitors: Quickshell.screens.map(screen => monitorComp.createObject(root, {
|
readonly property list<Monitor> monitors: variants.instances
|
||||||
screen
|
|
||||||
}))
|
|
||||||
|
|
||||||
function getMonitorForScreen(screen: ShellScreen): var {
|
function getMonitorForScreen(screen: ShellScreen): var {
|
||||||
return monitors.find(m => m.screen === screen);
|
return monitors.find(m => m.modelData === screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
function increaseBrightness(): void {
|
function increaseBrightness(): void {
|
||||||
const focusedName = Hyprland.focusedMonitor.name;
|
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)
|
if (monitor)
|
||||||
monitor.setBrightness(monitor.brightness + 0.1);
|
monitor.setBrightness(monitor.brightness + 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function decreaseBrightness(): void {
|
function decreaseBrightness(): void {
|
||||||
const focusedName = Hyprland.focusedMonitor.name;
|
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)
|
if (monitor)
|
||||||
monitor.setBrightness(monitor.brightness - 0.1);
|
monitor.setBrightness(monitor.brightness - 0.1);
|
||||||
}
|
}
|
||||||
|
|
@ -39,6 +37,14 @@ Singleton {
|
||||||
ddcProc.running = true;
|
ddcProc.running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Variants {
|
||||||
|
id: variants
|
||||||
|
|
||||||
|
model: Quickshell.screens
|
||||||
|
|
||||||
|
Monitor {}
|
||||||
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: ddcProc
|
id: ddcProc
|
||||||
|
|
||||||
|
|
@ -75,9 +81,9 @@ Singleton {
|
||||||
component Monitor: QtObject {
|
component Monitor: QtObject {
|
||||||
id: monitor
|
id: monitor
|
||||||
|
|
||||||
required property ShellScreen screen
|
required property ShellScreen modelData
|
||||||
readonly property bool isDdc: root.ddcMonitors.some(m => m.model === screen.model)
|
readonly property bool isDdc: root.ddcMonitors.some(m => m.model === modelData.model)
|
||||||
readonly property string busNum: root.ddcMonitors.find(m => m.model === screen.model)?.busNum ?? ""
|
readonly property string busNum: root.ddcMonitors.find(m => m.model === modelData.model)?.busNum ?? ""
|
||||||
property real brightness
|
property real brightness
|
||||||
|
|
||||||
readonly property Process initProc: Process {
|
readonly property Process initProc: Process {
|
||||||
|
|
@ -109,10 +115,4 @@ Singleton {
|
||||||
initProc.running = true;
|
initProc.running = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
|
||||||
id: monitorComp
|
|
||||||
|
|
||||||
Monitor {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,12 +60,9 @@ Singleton {
|
||||||
const clients = JSON.parse(data);
|
const clients = JSON.parse(data);
|
||||||
const rClients = root.clients;
|
const rClients = root.clients;
|
||||||
|
|
||||||
const len = rClients.length;
|
const destroyed = rClients.filter(rc => !clients.find(c => c.address === rc.address));
|
||||||
for (let i = 0; i < len; i++) {
|
for (const client of destroyed)
|
||||||
const client = rClients[i];
|
rClients.splice(rClients.indexOf(client), 1).forEach(c => c.destroy());
|
||||||
if (!clients.find(c => c.address === client?.address))
|
|
||||||
rClients.splice(i, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const client of clients) {
|
for (const client of clients) {
|
||||||
const match = rClients.find(c => c.address === client.address);
|
const match = rClients.find(c => c.address === client.address);
|
||||||
|
|
@ -88,9 +85,18 @@ Singleton {
|
||||||
splitMarker: ""
|
splitMarker: ""
|
||||||
onRead: data => {
|
onRead: data => {
|
||||||
const client = JSON.parse(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
|
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 networks = JSON.parse(data).map(n => [n[0] === "yes", parseInt(n[1]), parseInt(n[2]), n[3]]);
|
||||||
const rNetworks = root.networks;
|
const rNetworks = root.networks;
|
||||||
|
|
||||||
const len = rNetworks.length;
|
const destroyed = rNetworks.filter(rn => !networks.find(n => n[2] === rn.frequency && n[3] === rn.ssid));
|
||||||
for (let i = 0; i < len; i++) {
|
for (const network of destroyed)
|
||||||
const network = rNetworks[i];
|
rNetworks.splice(rNetworks.indexOf(network), 1).forEach(n => n.destroy());
|
||||||
if (!networks.find(n => n[2] === network?.frequency && n[3] === network?.ssid))
|
|
||||||
rNetworks.splice(i, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const network of networks) {
|
for (const network of networks) {
|
||||||
const match = rNetworks.find(n => n.frequency === network[2] && n.ssid === network[3]);
|
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 currentNamePath: `${StandardPaths.standardLocations(StandardPaths.GenericStateLocation)[0]}/caelestia/wallpaper/last.txt`.slice(7)
|
||||||
readonly property string path: `${StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]}/Wallpapers`.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
|
property bool showPreview: false
|
||||||
readonly property string current: showPreview ? previewPath : actualCurrent
|
readonly property string current: showPreview ? previewPath : actualCurrent
|
||||||
property string previewPath
|
property string previewPath
|
||||||
|
|
@ -84,23 +84,19 @@ Singleton {
|
||||||
command: ["fd", ".", root.path, "-t", "f", "-e", "jpg", "-e", "jpeg", "-e", "png", "-e", "svg"]
|
command: ["fd", ".", root.path, "-t", "f", "-e", "jpg", "-e", "jpeg", "-e", "png", "-e", "svg"]
|
||||||
stdout: SplitParser {
|
stdout: SplitParser {
|
||||||
splitMarker: ""
|
splitMarker: ""
|
||||||
onRead: data => {
|
onRead: data => wallpapers.model = data.trim().split("\n")
|
||||||
const list = data.trim().split("\n");
|
|
||||||
root.list = list.map(p => wallpaperComp.createObject(root, {
|
|
||||||
path: p
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
component Wallpaper: QtObject {
|
Variants {
|
||||||
required property string path
|
id: wallpapers
|
||||||
readonly property string name: path.slice(path.lastIndexOf("/") + 1, path.lastIndexOf("."))
|
|
||||||
}
|
|
||||||
|
|
||||||
Component {
|
|
||||||
id: wallpaperComp
|
|
||||||
|
|
||||||
Wallpaper {}
|
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