Skip to content

network applet: fix duplicate rows when a network gains a profile - #14076

Merged
clefebvre merged 1 commit into
linuxmint:masterfrom
IvanTheGeek:fix/wifi-new-profile-rebuild
Nov 2, 2026
Merged

clefebvre merged 1 commit into
linuxmint:masterfrom
IvanTheGeek:fix/wifi-new-profile-rebuild

Conversation

@IvanTheGeek

Copy link
Copy Markdown
Contributor

When a new access point (BSS) makes another saved profile valid for a Wi-Fi network that is already listed, _accessPointAdded() calls _accessPointRemoved() on the access point it has just added, then inserts a new item. #12417 added that call to take the network out of the menu first, but _accessPointRemoved() only destroys the item when the network's last access point goes. So:

  • the old row stays and a second one is added; more can pile up as the network goes and comes back, and they stay after it has gone until the next rebuild;
  • the new access point is dropped, so a profile valid only there cannot be activated from its row.

It happens with a profile locked to a BSSID or band, or a WPA3 profile when only one band offers WPA3. The fix sorts and rebuilds the section, as addConnection() does. That also keeps the More submenu right and gives the connected network no row; the re-insertion, older than #12417, gave it one. Only this rare event rebuilds; a new network is still inserted in place. As with any rebuild, if the menu is open at that moment, an expanded Wi-Fi submenu closes, and the menu may close if one of its Wi-Fi rows has the keyboard focus.

This goes with #14075; the two are meant to be merged together. On master, a network with two or more saved profiles stops at the TypeError that PR fixes before it gets here, so with that PR alone it reaches this bug. Each applies cleanly with or without the other, and with #14073 and #14074.

To reproduce, use a dual-band network you are not connected to and have no saved profile for, where both bands show the same security in nmcli -f SSID,CHAN,SECURITY dev wifi list and you can switch 5 GHz off on its own, such as a router. Switch 5 GHz off, wait until that command shows only the 2.4 GHz row, and add a profile locked to 5 GHz (use sae for a WPA3-only network):

nmcli connection add type wifi con-name t1 ssid "NAME" autoconnect no 802-11-wireless.band a wifi-sec.key-mgmt wpa-psk wifi-sec.psk not-the-real-password

Switch 5 GHz back on (nmcli dev wifi rescan speeds this up). On master the network gets a second row, and switching the whole network off leaves one behind until the menu is next rebuilt. With this change it has one row, and none is left. Don't click t1; clean up with nmcli connection delete t1.

Not changed here: a profile whose only BSS goes away stays listed.

Tested on: the same setup as #14075, with throwaway profiles locked to one band. One saved profile plus a 2.4 GHz-locked one, with 5 GHz back first: before this change (master's code here) the 2.4 GHz BSS was dropped and a second row stayed after the hotspot went off; with both changes the section was rebuilt once and one row tracked both bands. One locked profile per band: #14075 alone added a row each cycle; with both changes, none. Not tested: this change without #14075.

AI assistance: written with help from Claude Opus 5.5 (Anthropic); I reviewed it and tested it on my own machine.

A new access point can make another saved profile valid for a Wi-Fi
network that is already listed: one locked to a BSSID or band, or a
WPA3 profile when only one band offers WPA3. Since linuxmint#12417,
_accessPointAdded() then calls _accessPointRemoved() on the access
point it has just added, to take the network out of the menu before
re-inserting it. But _accessPointRemoved() only destroys the item
when the network's last access point goes, and this network keeps
its others.

So the old row stayed and a second one was added. The new access
point was also dropped, so a profile valid only there could not be
activated from its row. The extra rows could pile up each time the
network went and came back, and stayed after it had gone until the
next rebuild. The re-insertion, older than linuxmint#12417, also gave the
connected network a row, which it should not have.

Sort and rebuild the section instead, as addConnection() does; that
also keeps the More submenu right. The event is rare, but it can
come while the menu is open, since opening the menu starts a scan.
As on any other rebuild, an expanded submenu in the section then
closes, and the menu may close if a row in the section has the key
focus.

A new network is not affected: its access point is in no list yet,
so the call did nothing there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants