From bc446dabaf9c2a59444362800bf0ac6a7a3cd6be Mon Sep 17 00:00:00 2001 From: bbedward Date: Thu, 18 Sep 2025 18:19:06 -0400 Subject: [PATCH] network: never allow rescans during update, more selective parsing from gdbus monitor --- Services/NetworkService.qml | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/Services/NetworkService.qml b/Services/NetworkService.qml index 26099860..a68865b6 100644 --- a/Services/NetworkService.qml +++ b/Services/NetworkService.qml @@ -133,18 +133,30 @@ Singleton { command: lowPriorityCmd.concat(["gdbus", "monitor", "--system", "--dest", "org.freedesktop.NetworkManager"]) running: false + property var lastRefreshTime: 0 + property int minRefreshInterval: 1000 + stdout: SplitParser { splitMarker: "\n" onRead: line => { - if (line.includes("StateChanged") || line.includes("PrimaryConnectionChanged") || line.includes("WirelessEnabled") || line.includes("ActiveConnection")) { - refreshNetworkState() - } else if (line.includes("PropertiesChanged") && line.includes("org.freedesktop.NetworkManager.AccessPoint") && line.includes("'Strength'")) { - if (root.activeAccessPointPath && line.includes(root.activeAccessPointPath)) { - parseSignalStrengthFromDbus(line) + const now = Date.now() + if (line.includes("PropertiesChanged") && line.includes("org.freedesktop.NetworkManager.AccessPoint")) { + if (line.includes("'Strength'") && root.activeAccessPointPath && line.includes(root.activeAccessPointPath)) { + parseSignalStrengthFromDbus(line) + } + return + } + + if (line.includes("StateChanged") || + line.includes("PrimaryConnectionChanged") || + line.includes("WirelessEnabled") || + (line.includes("ActiveConnection") && line.includes("State"))) { + + if (now - nmStateMonitor.lastRefreshTime > nmStateMonitor.minRefreshInterval) { + nmStateMonitor.lastRefreshTime = now + refreshNetworkState() + } } - } else if (line.includes("PropertiesChanged") && !line.includes("AccessPoint") && !line.includes("LastSeen")) { - refreshNetworkState() - } } } @@ -403,7 +415,6 @@ Singleton { getWifiIP.running = true getCurrentWifiInfo.running = true getActiveAccessPoint.running = true - // Ensure SSID is resolved even if scan output lacks ACTIVE marker if (root.currentWifiSSID === "") { if (root.wifiConnectionUuid) { resolveWifiSSID.running = true @@ -456,7 +467,7 @@ Singleton { Process { id: getCurrentWifiInfo - command: root.wifiInterface ? lowPriorityCmd.concat(["nmcli", "-t", "-f", "IN-USE,SIGNAL,SSID", "device", "wifi", "list", "ifname", root.wifiInterface]) : [] + command: root.wifiInterface ? lowPriorityCmd.concat(["nmcli", "-t", "-f", "IN-USE,SIGNAL,SSID", "device", "wifi", "list", "ifname", root.wifiInterface, "--rescan", "no"]) : [] running: false stdout: SplitParser {