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/Brightness.qml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'services/Brightness.qml') diff --git a/services/Brightness.qml b/services/Brightness.qml index fabac1f..1687878 100644 --- a/services/Brightness.qml +++ b/services/Brightness.qml @@ -10,24 +10,22 @@ Singleton { id: root property var ddcMonitors: [] - readonly property list monitors: Quickshell.screens.map(screen => monitorComp.createObject(root, { - screen - })) + readonly property list 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 {} - } } -- cgit v1.2.3-freya